Showing posts with label Mobile Browser. Show all posts
Showing posts with label Mobile Browser. Show all posts

How to recognize Mobile Browser with Javascript for Android, iPhone, Symbian, Windows Mobile and Blackberry

With the deployment of advanced mobile phones (Android, iPhone, Symbian, Windows Mobile and Blackberry) we are experiencing the strongest growth of navigation via mobile browser. The most important sites are already taken care of and allocation to courses introducing their versions for browsers light taken from mobile phones. And you?

In this article we present a piece of JavaScript code that can come in handy if you intend to modify the site to make it compatible with mobile browsers.

Javascript function: How to recognize mobile browser

<script type="text/javascript"> / / <! [CDATA [ 
   var = Mobile 
   (Mobile) { 
       document.location = " http://www.yoursite.com/mobile.html ";
   }  / / ]]></ script>

How does it work?

The browser version is read from the property navigator.userAgent with Javascript that returns a string object with which you can find the name and version of any web browser

A sample output navigator.userAgent:
Mozilla/5.0 (Linux; U; Android 2.1-Update1; en-us;
ADR6300 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Mobile
 

Popular Posts

Most Reading

Tags

Android (474) Business (1) Food (1) Science (18) technology (132)

Nice Technology