I want to execute a javascript function only if the user is using an iPad / IPhone.
Something like that:
var checkifipadoriphone = true; //or false if(checkifipadoriphone){ executesomefuntion(); }
How to do it?
Thank!
function isiPhone(){ return ( //Detect iPhone //var isiPad = navigator.userAgent.match(/iPad/i) != null; (navigator.platform.indexOf("iPhone") != -1) || //Detect iPod (navigator.platform.indexOf("iPad") != -1) ); } if(isiPhone()){ executesomefuntion(); }
Review the page to see if you can use it to extract the browser type from the navigator object.