How do I make a Web page recognize if I'm logged on from the mobile side?
===============================
In writing their own site encountered such a problem, because the page calls a lot of JavaScript and CSS code, if the mobile side directly look at the effect is not good, in order to solve this problem, I think to let the page to identify whether the current login device is mobile, if it is mobile device, Then jump to a page that has been optimized for the mobile side. So how does it work?
Actually inserting a piece of simple JavaScript code into the header of the HTML can be implemented.
1<script type= "Text/javascript" >2 functionBrowserredirect () {3 varSuseragent =navigator.userAgent.toLowerCase (); 4 varBisipad = Suseragent.match (/ipad/i) = = "ipad"; 5 varBisiphoneos = Suseragent.match (/iphone os/i) = = "iphone OS"; 6 varBISMIDP = Suseragent.match (/midp/i) = = "MIDP"; 7 varBIsUc7 = Suseragent.match (/rv:1.2.3.4/i) = = "rv:1.2.3.4"; 8 varBISUC = Suseragent.match (/ucweb/i) = = "UCWeb"; 9 varBisandroid = Suseragent.match (/android/i) = = "Android"; Ten varBisce = Suseragent.match (/windows ce/i) = = "Windows CE"; One varBISWM = Suseragent.match (/windows mobile/i) = = "Windows Mobile"; A if((Bisipad | | bisiphoneos | | bismidp | | bIsUc7 | | bisuc | | bisandroid | | bisce | |biswm)) { -window.location.href= "page path to jump"; - } the } -Browserredirect (); </script>
How's that, simple?