First determine whether the page is Android or iOS, and then use Ajax to return the results via the interface URL, recorded in the log log to count the number of Android and iOS users accessing the page (data statistics)
<script type= "Text/javascript" >window.onload=function() {//page is executed immediately after loading varU =navigator.useragent; varisandroid = U.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1;//android Terminal varIsios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);//ios Terminal if(Isandroid = =true){ <!--alert (' Whether it's Android: ' +isandroid '); -$.ajax ({type:"POST", URL:"Interface Address",//interface address of the request data: {"SystemType": "Android"},//android if a constant must be quoted, the variable does not need to be quoted DataType:"JSON", Success:function(msg) {alert (msg); }, Error:function(Error) {alert ("Android Submission failed"); } }); }Else if(Isios = =true){ <!--alert (' is iOS: ' +isios '); -$.ajax ({type:"POST", URL:"Interface Address", data: {"SystemType": "ios"}, DataType:"JSON", Success:function(msg) {alert (msg); }, Error:function(Error) {alert ("iOS submission failed"); } }); } }</script>
Determines whether the mobile user opens the page with Android or iOS and returns the results to the URL interface via Ajax, passing it back