0

I can't figure out how to detect a "dumb" phone browser using jQuery/JavaScript. I have a desktop/tablet, a smartphone, and a dumbphone version of my website. The smartphone version of the site is too heavy and slow for dumb phones so I want to redirect them to the "lite" version instead.

A good example of this would be Facebook. When I open Facebook on a dumb phone browser, the users get redirected to hte lite version. How do I do that same behavior?

NOTE: I am using JavaScript and not PHP beacuse of platform constraints. (It is on Tumblr.)

Propeller
  • 2,465
  • 6
  • 35
  • 49

2 Answers2

0

In your javascript you will need to detect the user agent variable (this is what each browser uses to identify itself).

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
 // Redirect code goes here
 window.location = "someplace.com";
}

Essentially you will have to manually enter the types to test for in this and have an if/else statement for each case. (See http://www.w3schools.com/jsref/prop_nav_useragent.asp and http://useragentstring.com/pages/useragentstring.php)

Elianora
  • 194
  • 1
  • 13
0

Another good way would be check if certain features are present in the browser, like the http://modernizr.com/ library does. This might be better performance wise and you won't have to update the user-agent string every-time you find a "dumbphone".

piatek
  • 376
  • 1
  • 6