Skip to content Skip to sidebar Skip to footer

Detect Mobile Browser And Javascript Support

I want to detect if the request is coming from a mobile browser (i m using java/jsp) Now when i access the page from my samsung mobile phone i get the user agent header as: - SAMS

Solution 1:

You can use something like WURFL to see if the browser has some level of Javascript support.

You can't, however, tell if the browser has Javascript enabled or which Javascript features are supported by the particular version of the browser on that particular device.

You should, instead, use progressive enhancement in the browser to add Javascript-based functionality by testing for the specific functionality required.

Solution 2:

Have you tried using something like Modernizr? In general you shouldn't detect browsers because there are so many of them and you just cannot know every feature of every version of every browser on every platform, not to even mention that you can't even be sure that the user agent header is right. You should detect features instead.

There are many more browsers and more incompatibilities on the mobile platforms than on the desktop. After trying to build portable websites for mobile browsers you'll actually start to love IE6 for it's compliance with standards. That's why I recommend using something like the jQuery Mobile to do the hard work of figuring out the differences and inconsistencies between platforms and giving you a nice and consistent API. Otherwise here's a list of platforms that you have to consider supporting: http://jquerymobile.com/gbs/

Solution 3:

Using www.handsetdetection.com I would do a detection server side. If the browser is poor quality or unsophisticated then redirect them to the simple mobile page, if the browser is decent then send them to your mobile page.

The detection will be happening on your main site. To allow visitors to move from your mobile site back to your normal site check the http referrer. If the referrer is you mobile site then do not redirect them back.

Hope that helps.

Solution 4:

Try this: (although this makes the detection from the client side)

<!DOCTYPE html><html><head><title> going from here to the real page... </title></head><body><noscript>
      Javascript is disabled.
      <metaHTTP-EQUIV="REFRESH"content="0; url=http://www.yourSite.com/yourStaticPage.html/"></noscript><scripttype="text/javascript">// most of smartphons support this orientation property: if (typeofwindow.orientation !== 'undefined'){   
             window.location.replace("http://yourSite.com/yourMobilePage.html");
         }
         else {          
             window.location.replace("http://yourSite.com/yourDesktopPage.html");
         }
    </script></body></html>

Post a Comment for "Detect Mobile Browser And Javascript Support"