Friday, February 4, 2011

iPad Detection Using JavaScript

Following fragment of code helps in detecting whether an application is being previewed in a iPad or a normal web client.

// For use within normal web clients 
var isiPad = navigator.userAgent.match(/iPad/i) != null;

// For use within iPad developer UIWebView
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua)

For more info take a look at http://davidwalsh.name/detect-ipad

Hope this helps :)

No comments:

Post a Comment