Posted By

humanoid on 04/13/10


Tagged

browser jquery detection iphone ipod iPad


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

michelfraga
legacye
tyfi84
WFendler
chrisaiv
Bonky
dubogii
Ethyde
alberfp
ik


iphone ipad ipod Detect


 / Published in: jQuery
 

execute javaScript only for iphone / ipad / ipod using jQuery, triggered on page load

  1. jQuery(document).ready(function($){
  2. var deviceAgent = navigator.userAgent.toLowerCase();
  3. var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
  4. if (agentID) {
  5.  
  6. // do something special
  7.  
  8. }
  9. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: DrCord on November 4, 2010

Great piece of code, very useful to sniff out iOS device to compensate for rendering problems. I wrote an article that references your code in a list of useful iOS snippets and resources. http://www.blog.cordslatton.com/2010/11/debugging-ios-…ri-ipad-iphone/

Posted By: DrCord on November 4, 2010

That link to the article was truncated, here is the full link: http://www.blog.cordslatton.com/2010/11/debugging-ios-mobile-safari-ipad-iphone/

Posted By: WFendler on December 2, 2010

Just used this to fix a "position:fixed" problem in mobile safari. Thanks!

Posted By: fauverism on September 2, 2011

Love this, thanks much!

You need to login to post a comment.