Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i disable a certain javascript on iphone/ipad or other mobile devices?

I got this for IE browsers,

var IE = /*@cc_on!@*/false;

if (IE) {
    // IE.
} else {
    // Others.
}

but how would i do the same for iphone/ipad/mobiledevices? (do not want to redirect to another page on any mobile devices)

like image 374
user295292 Avatar asked Dec 28 '22 18:12

user295292


1 Answers

You may want to check the user agent string as follows:

var userAgent = navigator.userAgent;

if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
   // iPad or iPhone
}
else {
   // Anything else
}
like image 58
Daniel Vassallo Avatar answered Dec 31 '22 09:12

Daniel Vassallo