JavaScript:Detecting smartphones

From virtualMV2015wiki
Jump to: navigation, search
 Home  JavaScript <

Detect Symbian S60 Smartphones.

The most popular smartphone platform in the world is Symbian S60. Used primarily by Nokia and a few other manufacturers, S60 features an extremely capable browser (Hand, 2008).[1] Other mobile device detection code is also on this page.

Hand(2008) also indicates that this may not work as:

  • Users can turn off JavaScript
  • Not all mobile phones support JavaScript (particularly if they support WAP/WML)
  • Requires the useragent string. (Some browsers emulate others so give false results)
  • Mobile operators (e.g. Telecom, vodaphone) can change the useragent string


var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";
 
//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();
 
//**************************
// Detects if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function DetectS60OssBrowser()
{
   return uagent.search(engineWebKit) > -1 &&
     (uagent.search(deviceS60) > -1 || uagent.search(deviceSymbian) > -1);
}
function load()
{ 
if ( DetectS60OssBrowser() ) 
{ window.location = 'http://www.yourdomain.com/mobile' }; }
}

// this is not tested but should redirect the page

<body onload="load()">

Icon References.png References

  1. Hand, A. (2008). Detecting Smartphones Using JavaScript :: Hand Interactive Resource. Retrieved April 17, 2009 from http://www.hand-interactive.com/resources/detect-mobile-javascript.htm

JavaScript:Detecting smartphones. (2017). In virtualMV's ( Michael Verhaart ) wiki. Retrieved December 18, 2017, from http://www.virtualmv.com/wiki/index.php?title=JavaScript%3ADetecting_smartphones    (zotero)