Mobile phone users do not have the bandwidth and transfer speed to load Web pages with large graphics and text. Website owners detect mobile phone browsers to forward the user to a section of the website optimized for mobile browsers. You can detect a mobile phone browser using JavaScript that loads when the user opens the website.
Instructions
- 1Create the script tags that contain the JavaScript browser detection. Type the following tags within the body of the HTML code of the website:<script type="text/javascript"> </script>
- 2Create the variable to assign the user's browser name. Type the following code to create a JavaScript variable:var browser;
- 3Detect the mobile phone browser and redirect accordingly. The browser type is contained in the "user agent" function sent by the user's browser. The following code reads the user agent value:browser = navigator.userAgent.toLowerCase();
- 4Redirect the user to a mobile section of your website. For instance, the following code redirects the user if the "iPhone" browser is detected:if (browser == 'iphone') {window.location = 'mobile/index.php';}
- 1
Hello,
ReplyDeleteThere are many more browsers and more incompatibilities on the mobile platforms than on the desktop. After trying to build portable websites for mobile browsers. Detect the mobile phone browser and redirect accordingly. The browser type is contained in the user agent function sent by the user's browser. Thanks..
Mobile Survey