Reputation: 3220
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!
Upvotes: 3
Views: 3767
Reputation: 3220
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();
}
Upvotes: 3