js如何判断浏览器是否360类型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js如何判断浏览器是否360类型相关的知识,希望对你有一定的参考价值。

代码如下:

<%@ 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>

参考技术A //  封装判断浏览器类型和版本信息的类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() 
trythis.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>

参考技术B 哥们,你无药可救了。
360浏览器他有2种模式,第一是ie内核,第二是webkit内核,所有你只需判断属于ie几 还是webkit就行了。
核心代码:
navigator.userAgent本回答被提问者采纳
参考技术C var UA=navigator.userAgent;
is360se = UA.toLowerCase().indexOf('360se')>-1 ? true : false;
alert(is360se );

js如何判断浏览器类型,包括手机浏览器的?

O疼的兼容性问题

在JS中判断浏览器的类型,估计是每个编辑过页面的开发人员都遇到过的问题。在众多的浏览器产品中,IE、Firefox、Opera、Safari........众多品牌却标准不一,因此时常需要根据不同的浏览器,甚至相同浏览器不同版本做不同的操作,因此,知晓浏览器的判断方法,还是很重要的。下面列举一下常用的判断方法:
1、判断浏览器是否为IE
document.all ? \'IE\' : \'others\':在IE下document.all值为1,而其他浏览器下的值为0;
navigator.userAgent.indexOf("MSIE")>0 ? \'IE\' : \'others\':navigator.userAgent是描述用户代理信息。
navigator.appName.indexOf("Microsoft") != -1 ? \'IE\' : \'others\':navigator.appName描述浏览器名称信息。
2、判断IE版本
navigator.appVersion.match(/6./i)=="6." ? \'IE6\' : \'other version\':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE6;
navigator.userAgent.indexOf("MSIE 6.0")>0 ? \'IE7\' : \'other version\':同上;
navigator.appVersion.match(/7./i)=="7." ? \'IE7\' : \'other version\':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE7;
navigator.userAgent.indexOf("MSIE 7.0")>0 ? \'IE7\' : \'other version\':同上;
navigator.appVersion.match(/8./i)=="8." ? \'IE8\' : \'other version\':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE8;
navigator.userAgent.indexOf("MSIE 8.0")>0 ? \'IE8\' : \'other version\':同上。
3、JS获取浏览器信息
浏览器代码名称:navigator.appCodeName
浏览器名称:navigator.appName
浏览器版本号:navigator.appVersion
对Java的支持:navigator.javaEnabled()
MIME类型(数组):navigator.mimeTypes
系统平台:navigator.platform
插件(数组):navigator.plugins
用户代理:navigator.userAgent

DEMO:
Js代码
<script language="JavaScript">
<!--
function getOs()

var OsObject = "";
if(navigator.userAgent.indexOf("MSIE")>0)
return "MSIE";

if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)
return "Firefox";

if(isSafari=navigator.userAgent.indexOf("Safari")>0)
return "Safari";

if(isCamino=navigator.userAgent.indexOf("Camino")>0)
return "Camino";

if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)
return "Gecko";



alert("您的浏览器类型为:"+getOs());
-->
</script>
参考技术A http://www.cnblogs.com/leadzen/archive/2008/09/06/1285764.html
http://www.2cto.com/kf/201108/101121.html
http://blog.csdn.net/momoxsy/article/details/11560081最后这个有单独判断360的,手机浏览器没试过,可以自己百度本回答被提问者采纳

以上是关于js如何判断浏览器是否360类型的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript-js怎样判断手机浏览器

js如何判断浏览器类型,包括手机浏览器的?

JS如何判断浏览器滚动条的位置

js判断浏览器类型怎么写

js如何判断浏览器

如何判断出一个js对象是不是一个dom对象