zoukankan      html  css  js  c++  java
  • 判断qq浏览器和uc浏览器?

    判断在iphone手机上打开的是uc浏览器还是qq浏览器

    <html lang="en">
        <head>
            <meta charset="utf-8">
            <script src="./jquery-2.1.4.min.js"></script>
        </head>
    <!-- navigator.userAgent.indexOf(' QQ') > -1 -->
        <body>
        	<div style="height: 200px; 200px;background-color: red" id="test"></div>
        </body>
    </html>
    <script>
    
    	 if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){ 
               $("#test").css("background-color",'blue'); 
               if(navigator.userAgent.indexOf('UCBrowser') > -1){ 
                    $("#test").css("background-color",'black'); 
               }else if(new RegExp('MQQBrowser').test(navigator.userAgent)){ 
                    $("#test").css("background-color",'yellow'); 
               }
             
    	 }
    </script> 

     1.判断是不是iphone手机?

    /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)

    是true就执行下一步

    2.判断uc浏览器?

    navigator.userAgent.indexOf('UCBrowser') > -1

    3.判断qq浏览器

    new RegExp('MQQBrowser').test(navigator.userAgent)

    其实你只要打印一个alert(navigator.userAgent),在那个浏览器打开就好了,就知道有没有错~~~~~

    这是我用一个起作用就变色的来试

  • 相关阅读:
    Linux常用命令集合
    运用栈实现表达式求值(+,-,*,/运算)
    队列
    变参函数
    C语言--递归程序的设计
    指针的灵活应用--内核链表中的container_of
    C语言-求回文数字
    压力测试和负载测试
    测试理论
    Dubbo接口调用
  • 原文地址:https://www.cnblogs.com/antyhouse/p/8918885.html
Copyright © 2011-2022 走看看