js判断是什么类型的浏览器
复制代码代码如下所示:
如果(window.sidebar对象=功能型(窗口。侧边栏)= typeof(窗口。侧边栏。addpanel)) / /火狐

{
}
else if(document.all = =对象类(窗口。外)) / /伊江

{
}

js是用来区分IE和其他浏览器和IE6-8之间。

1、document.all
2,!window.activexobject;

该方法的使用如下:

如果(文件all){
警报(浏览器);
其他{ }
警报(非IE浏览器);
}

如果(!!!窗口。ActiveX对象){
警报(浏览器);
其他{ }
警报(非IE浏览器);
}

以下是区分IE6,IE7和IE8的方法:

无功议=!window.activexobject;
无功isie6 =议!Window.XMLHttpRequest;
无功isie8 =议!document.documentmode;
无功isie7 =议!isie6!isie8;
如果(议){
如果(isie6){
警报(IE6 );
} else if(isie8){
警报(IE8 );
} else if(isie7){
警报(IE7 );
}
}

首先,我们确保浏览器是IE,并且我们每次都有一个测试。如果你对此有疑问,你可以测试它。

我用它直接的判断,也可以被用来作为变量声明。据说,Firefox也将加入document.all在未来,因此建议第二方法应该被使用,它应该是安全的。

Navigator.userAgent.indexOf()是用来区分多个浏览器。代码示例如下所示:
复制代码代码如下所示:


var浏览器{
版本:函数(){
VaR U = navigator.useragent,程序= navigator.appversion;
返回{
三叉戟:u.indexof('trident)> 1, / / IE内核
Presto:u.indexof('presto)> 1, / /歌剧内核
Webkit:u.indexof('applewebkit)> 1,苹果、谷歌/内核
壁虎:u.indexof('gecko)> 1 u.indexof('khtml)= 1,Firefox /内核
手机:u.match( / applewebkit移动。*。* /)| |!!!! / / u.match( / / applewebkit),无论是移动终端
网间网操作系统:!u.match!((i);};+;(u;CPU + Mac)操作系统;)
安卓:u.indexof('android)- 1 u.indexof('linux)| | > > 1, / / Android终端或UC浏览器
iPhone:u.indexof('iphone)- 1 u.indexof('陆委会')| | > > / / 1,无论是iPhone或qqhd浏览器
iPad:u.indexof('ipad)- 1 / iPad >,是否
应用:u.indexof('safari)= 1 / /网页不在头的底部和程序应。
};
(})
}

document.writeln(是移动终端:+浏览器版本。移动);
document.writeln(iOS终端:+浏览器,iOS版本。);
document.writeln(Android终端:+浏览器,Android版本。);
document.writeln(是iPhone:+浏览器版本。iPhone);
document.writeln(是否iPad:+浏览器版本。iPad);
document.writeln(导航。用户代理);



Javascript,不管是PC浏览器还是移动浏览器,都是由用户代理来判断的。