[JavaScript] uses JavaScript. If the mobile browser accesses the PC page, the page automatically jumps to the mobile phone version page, and the javascriptpc
In fact, you don't need to write it by yourself, because there is a very good js written on the Internet.
To achieve the following results, if you access this page from a PC or tablet, the page for PC is displayed. If you access this page by mobile phone, the page for mobile phone is displayed, and the page for PC is not loaded, jump directly.
First, the directory structure is as follows:
Uaredirect. JS in the js folder is down from the Internet, and its code is as follows:
function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+"/#m/"+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+"/#m/"+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match("fromapp")){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf("://");if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www\./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(".","\\.");var a=new RegExp("\\."+c+"$");if(b.match(a)){return 2}else{return 0}}}};You can directly copy and use it, and then add the following to the page header of the PC version:
<script src="js/uaredirect.js" type="text/javascript"></script><script>uaredirect("ml.html");</script>This shows the effect.
The complete code of pc.html is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The ml.html code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> There is nothing special about it. They are simple HTML pages that are no longer simple.