I want to execute a javascript function, only if the user is using an IPad / IPhone.
Something like this:
var checkifipadoriphone = true; //or false
if(checkifipadoriphone){
executesomefuntion();
}
How does one do this?
Thanks!
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();
}
Check out this page to see if you can use it to extract the browser type from the navigator object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With