Home >Web Front-end >HTML Tutorial >Automatically determine the mobile version and PC version

Automatically determine the mobile version and PC version

WBOY
WBOYOriginal
2016-09-27 14:05:221392browse



Welcome to the mobile version
<script><br>var ua = navigator.userAgent;<br>var US = {<br>  Android:function () { //Android<br>                                                                                                                             ,<br> IOS:function(){ //IOS<br> return ua.match(/iPhone|iPad|iPod/i)?true:false;<br> },<br> //This is actually not necessary, you don’t need to judge this, after all IE is an ancient thing <br>                                                                                                                   use using using using using using using out off out out out out out out out out of ’ ’ s ’ ‐ to ‐ ‐‐‐‐‐ IE )||US.BlackBerry()||US.IOS()||US.Windows();<br> }<br>}<br>if(US.isMobile()==false){<br> window.location = "http:// www.baidu.com"; //If accessed from a computer, jump to the specified URL. Take Baidu as an example<br>}<br></script>


Welcome to the mobile version







Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn