admin管理员组文章数量:1023221
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!
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!
Share Improve this question edited Apr 11, 2013 at 15:39 James Cazzetta asked Apr 2, 2012 at 11:18 James CazzettaJames Cazzetta 3,2206 gold badges36 silver badges55 bronze badges 1- 3 possible duplicate of Detect iPad users using jQuery? – Felix Kling Commented Apr 2, 2012 at 11:19
2 Answers
Reset to default 3function 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.
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!
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!
Share Improve this question edited Apr 11, 2013 at 15:39 James Cazzetta asked Apr 2, 2012 at 11:18 James CazzettaJames Cazzetta 3,2206 gold badges36 silver badges55 bronze badges 1- 3 possible duplicate of Detect iPad users using jQuery? – Felix Kling Commented Apr 2, 2012 at 11:19
2 Answers
Reset to default 3function 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.
本文标签: jqueryHow to execute a javaScript function only when using an IPhoneIPadStack Overflow
版权声明:本文标题:jquery - How to execute a javaScript function only when using an IPhoneIPad - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745596499a2158202.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论