use*_*292 4 javascript iphone mobile mobile-safari ipad
我在IE浏览器中得到了这个,
var IE = /*@cc_on!@*/false;
if (IE) {
// IE.
} else {
// Others.
}
Run Code Online (Sandbox Code Playgroud)
但我如何为iphone/ipad/mobiledevices做同样的事情?(不想重定向到任何移动设备上的其他页面)
您可能需要检查用户代理字符串,如下所示:
var userAgent = navigator.userAgent;
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
// iPad or iPhone
}
else {
// Anything else
}
Run Code Online (Sandbox Code Playgroud)