/ Published in: jQuery
execute javaScript only for iphone / ipad / ipod using jQuery, triggered on page load
Expand |
Embed | Plain Text
jQuery(document).ready(function($){ var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipod|ipad)/); if (agentID) { // do something special } });
Comments
Subscribe to comments
You need to login to post a comment.

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/
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/
Just used this to fix a "position:fixed" problem in mobile safari. Thanks!
Love this, thanks much!