admin管理员组

文章数量:1300203

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)

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)

Share Improve this question edited May 2, 2010 at 4:09 Daniel Vassallo 345k72 gold badges512 silver badges446 bronze badges asked May 2, 2010 at 4:01 user295292user295292 2003 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

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
}

That should be a bit of a problem because every app makes its own Header. My apache server gets this as Browser: [APPNAME]/1.0_CFNetwork/459_Darwin/10.3.0

You could search for Darwin, but I don't know if this is waterproof.

A JS-Snippet should look like that:

if (navigator.userAgent.indexOf("Firefox") != -1)
{
   document.write('You're using Mozilla Firefox');
}

本文标签: how do i disable a certain javascript on iphoneipad or other mobile devicesStack Overflow