Judge qq browser and uc browser?

Determine whether the uc browser or the qq browser is opened on the iphone

<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;width: 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. Determine whether it is an iPhone or not?

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

If it is true, go to the next step

2. Judge the uc browser?

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

3. Judge QQ browser

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

In fact, you only need to print an alert (navigator.userAgent), open it in that browser, and you will know if there is something wrong~~~~~

This is what I tried with one that changes color when it works

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324690810&siteId=291194637