js如何判断浏览器是不是360类型
4个回答
2016-01-08 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base >
<title></title>
<script>
function bro(){
var is360 = false;
var isIE = false;
if (window.navigator.appName.indexOf("Microsoft") != -1){
isIE= true;
}
if(isIE&&(window.navigator.userProfile+'')=='null'){
is360 = true;
}
if(is360){
document.body.innerText = '360浏览器';
}else if(isIE){
document.body.innerText = 'IE浏览器';
}
}
</script>
</head>
<body onload="bro();">
</body>
</html>
展开全部
// 封装判断浏览器类型和版本信息的类LB (全名LBrowser)
var LB = {
appName : null,// 浏览器类型
lUserAgent : null,
userAgent : navigator.userAgent,
appVersion : null, // 浏览器版本
fullApp : null,// 类型+版本
apps:["ie","firefox","opera","safari","chrome"],
I:"ie",F:"firefox",O:"opera",S:"safari",C:"chrome",
getAppName : function(){
this.appName = navigator.appName;
return this.appName;
},
getLUserAgent : function(){
this.lUserAgent = navigator.userAgent.toLowerCase();
// this.lUserAgent = "mozilla/5.0 (windows; u; windows nt 5.2) gecko/2008070208 firefox/3.0.1";
// this.lUserAgent = "mozilla/5.0 (macintosh; ppc mac os x; u; en) opera 8.0";
// this.lUserAgent = "mozilla/5.0 (windows; u; windows nt 5.2) applewebkit/525.13 (khtml, like gecko) version/3.1 safari/525.13";
// this.lUserAgent = "opera/8.0 (macintosh; ppc mac os x; u; en)";
// this.lUserAgent = "mozilla/5.0 (windows; u; windows nt 5.2) gecko/2008070208 test/3.0.1";
return this.lUserAgent;
},
whichApp : function(){
var lu = this.getLUserAgent();
if(this.isie()){
return this.appName = "ie";
}else if(lu.indexOf('firefox') != -1){ // not contains getBoxObjectFor always
return this.appName = "firefox";
}else if(window.opera || (lu.indexOf('opera') != -1 && lu.indexOf('chrome') == -1)){ // not contains chrome
return this.appName = "opera";
}else if((lu.indexOf('safari') != -1 && lu.indexOf('version') != -1)){ // chrome : window.openDatabase also
return this.appName = "safari";
}else if(lu.indexOf('chrome') != -1){// contains opera
return this.appName = "chrome";
}else{
throw new Error("Sorry ! Check The AppName Failure ! Please Update The 'LB' Plugin !");
return this.appName = null;
}
},
whichVersion : function(){
try{this.whichApp();}catch(ex){}
if("ie" == this.appName){
var reg = /msie\s+[\d\.]+/gi;
return this.appVersion = this.lUserAgent.match(reg)[0].split(" ")[1];
}else if("firefox" == this.appName){
var reg = /firefox\s*\/[\d\.]+/gi;
return this.appVersion = this.lUserAgent.match(reg)[0].split("/")[1];
}else if("opera" == this.appName){
var reg = /opera(\/)?\s*[\d\.]+/gi;
return this.appVersion = this.lUserAgent.match(reg)[0].indexOf('/') != -1 ? this.lUserAgent.match(reg)[0].split("/")[1] : this.lUserAgent.match(reg)[0].split(" ")[1];
}else if("chrome" == this.appName){
var reg = /chrome\s*\/[\d\.]+/gi;
return this.appVersion = this.lUserAgent.match(reg)[0].split("/")[1];
}else if("safari" == this.appName){
var reg = /version\s*\/[\d\.]+/gi;
return this.appVersion = this.lUserAgent.match(reg)[0].split("/")[1];
}else{
throw new Error("Sorry ! Check The AppVersion Failure ! Please Update The 'LB' Plugin !");
return this.appVersion = null;
}
},
isie : function(){
return null != window.ActiveXObject;
},
init : function(){
this.getLUserAgent();
try{
this.whichApp();
this.whichVersion();
}catch(ex){
alert(ex);
}
this.fullApp = this.appName + this.appVersion;
}
};
<body onload="LB.init();">
</body>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哥们,你无药可救了。
360浏览器他有2种模式,第一是ie内核,第二是webkit内核,所有你只需判断属于ie几 还是webkit就行了。
核心代码:
navigator.userAgent
360浏览器他有2种模式,第一是ie内核,第二是webkit内核,所有你只需判断属于ie几 还是webkit就行了。
核心代码:
navigator.userAgent
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var UA=navigator.userAgent;
is360se = UA.toLowerCase().indexOf('360se')>-1 ? true : false;
alert(is360se );
is360se = UA.toLowerCase().indexOf('360se')>-1 ? true : false;
alert(is360se );
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询