- function AppInfo () {
- var browser = {
- MSIE: false, Firefox: false, Opera: false, Safari: false,
- Chrome: false, Netscape: false, appname: ' unknown ', version:0
- },
- useragent = Window.navigator.userAgent.toLowerCase ();
- if (/(Msie|firefox|opera|chrome|netscape) \d+ (\d[\d.] *)/.test (useragent)) {
- BROWSER[REGEXP.$1] = true;
- Browser.appname = regexp.$1;
- Browser.version = regexp.$2;
- } Else if (/version\d+ (\d[\d.) *). *safari/.test (useragent)) { //Safari
- Browser.safari = true;
- Browser.appname = ' Safari ';
- Browser.version = regexp.$2;
- }
- return browser;
- }
- Invoke Example
- var myos = AppInfo ();
- If the current browser is IE, pop up the browser version, otherwise pop up the current browser name and version
- if (Myos.msie) {
- alert (myos.version); Pop-up IE version
- } Else {
- Alert (Myos.appname + myos.version);
- }
Determine if the browser is roaming
- function AppInfo () {
- var browser = {
- MSIE: false, Firefox: false, Opera: false, Safari: false,
- Chrome: false, Netscape: false, appname: ' unknown ', version:0
- },
- useragent = Window.navigator.userAgent.toLowerCase ();
- if (/(Maxthon|firefox|opera|chrome|netscape) \d+ (\d[\d.] *)/.test (useragent)) {
- BROWSER[REGEXP.$1] = true;
- Browser.appname = regexp.$1;
- Browser.version = regexp.$2;
- } Else if (/version\d+ (\d[\d.) *). *safari/.test (useragent)) { //Safari
- Browser.safari = true;
- Browser.appname = ' Safari ';
- Browser.version = regexp.$2;
- }
- return browser;
- }
- Invoke Example
- var myos = AppInfo ();
- If the current browser is IE, pop up the browser version, otherwise pop up the current browser name and version
- if (Myos.msie) {
- alert (myos.version); Pop-up IE version
- } Else {
- Alert (Myos.appname + myos.version);
- }
Determine browser type