精准判断是360、IE和其他浏览器
2024-08-30 07:01:20
function myexplorer(){
var explorer = window.navigator.userAgent;
if (!!window.ActiveXObject || "ActiveXObject" in window){//IE
if (!window.XMLHttpRequest){
return myexplorer="IE"; //IE6
}else if (window.XMLHttpRequest && !document.documentMode){
return myexplorer="IE"; //IE7
}else if (!-[1,] && document.documentMode && !("msDoNotTrack" in window.navigator)){
return myexplorer="IE"; //IE8
}else{//IE9 10 11
var hasStrictMode=(function(){
"use strict";
return this===undefined;
}());
if (hasStrictMode){
if (!!window.attachEvent){
return myexplorer="IE"; //IE10
}else{
return myexplorer="IE"; //IE11
}
}else{
return myexplorer="IE"; //IE9
}
}
}else{//非IE
//application/vnd.chromium.remoting-viewer 可能为360特有
var is360 = _mime("type", "application/vnd.chromium.remoting-viewer"); if (isChrome() && is360) {
return myexplorer= "360";
}else{
return myexplorer= "other"; //其他浏览器
}
}
} var browser = myexplorer();
if(browser == "IE" || browser == "360"){
get_video_list();
}else{
alert("其他");
} //检测是否是谷歌内核(可排除360及谷歌以外的浏览器)
function isChrome(){
var ua = navigator.userAgent.toLowerCase(); return ua.indexOf("chrome") > 1;
}
//测试mime
function _mime(option, value) {
var mimeTypes = navigator.mimeTypes;
if(mimeTypes){
for (var mt in mimeTypes) {
if (mimeTypes[mt][option] == value) {
return true;
}
}
return false;
}
} 方法二
$.browser = function () {
var userAgent = navigator.userAgent;
var isOpera = userAgent.indexOf("Opera") > -1;
if (isOpera) {
return "Opera"
};
if (userAgent.indexOf("Firefox") > -1) {
return "Firefox";
}
if (userAgent.indexOf("Chrome") > -1) {
if (window.navigator.webkitPersistentStorage.toString().indexOf('DeprecatedStorageQuota') > -1) {
return "Chrome";
} else {
return "360";
}
}
if (userAgent.indexOf("Safari") > -1) {
return "Safari";
}
if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
return "IE";
};
}
最新文章
- div悬浮
- MyBatis学习总结(四)——解决字段名与实体类属性名不相同的冲突(转载)
- 纯jsp用户登录系统
- C# 创建Windows Service
- sql语句原则
- [转]UDP/TCP穿越NAT的P2P通信方法研究(UDP/TCP打洞 Hole Punching)
- UVA 11181 dfs 概率
- OC - 29.自定义布局实现瀑布流
- [BZOJ 3747] [POI 2015] Kinoman【线段树】
- Java知识点复习
- this笔记
- 0_Simple__simpleAtomicIntrinsics + 0_Simple__simpleAtomicIntrinsics_nvrtc
- 2017C语言程序设计预备作业
- Docker学习(1)安装
- 从git中删除 .idea 目录
- MVC 之 缓存机制(一)
- 设计模式之单一职责原则(iOS开发,代码用Objective-C展示)
- Chrome V8引擎的一点认识
- selenium 基本常用操作
- cocos2dx 3.2 解决输入框(TextField,TextFieldTTF) 中文乱码问题
热门文章
- Tensorflow卷积接口总结
- Ubuntu midi 播放
- 洛谷 P3621 [APIO2007]风铃【贪心】
- 比特币搬砖对冲策略Python源码
- php安装的扩展php -m可以看到,但是phpinfo()看不到,php-fpm关闭了重新打开还是不行?
- 进击的Python【第十三章】:Web前端基础之HTML与CSS样式
- Ubuntu Server 上安装pip后pip命令报错的解决办法
- C# DataTable的详细用法[转]
- gcc 编译 c++ 程序(转载)
- [转]C#委托Action、Action<;T>;、Func<;T>;、Predicate<;T>;