Posted By

robksawyer on 08/05/09


Tagged

phone detection mobile cell iphone client-side


Versions (?)

Client-side mobile device detection


 / Published in: JavaScript
 

URL: http://www.phpdevblog.net/2009/01/detecting-mobile-devices.html

  1. function Client() {
  2. }
  3.  
  4. Client.prototype.mobileClients = [
  5. "midp",
  6. "240x320",
  7. "blackberry",
  8. "netfront",
  9. "nokia",
  10. "panasonic",
  11. "portalmmm",
  12. "sharp",
  13. "sie-",
  14. "sonyericsson",
  15. "symbian",
  16. "windows ce",
  17. "benq",
  18. "mda",
  19. "mot-",
  20. "opera mini",
  21. "philips",
  22. "pocket pc",
  23. "sagem",
  24. "samsung",
  25. "sda",
  26. "sgh-",
  27. "vodafone",
  28. "xda",
  29. "iphone",
  30. "android"
  31. ];
  32.  
  33. Client.prototype.isMobileClient = function(userAgent)
  34. {
  35. userAgent=userAgent.toLowerCase();
  36. for (var i in this.mobileClients) {
  37. if (userAgent.indexOf(this.mobileClients[i]) != -1) {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43.  
  44. var client = new Client();
  45. client.isMobileClient(navigator.userAgent);

Report this snippet  

You need to login to post a comment.