我可以使用以下代码检查iPhone:
(navigator.userAgent.match(/iPhone/i))
但我希望使用此userAgent定位Windows Phone:
Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1;
Motorola_ES405B_19103; Windows Phone 6.5.3.5)
有没有办法做到这一点?
答案 0 :(得分:44)
Windows Phone
当然似乎是您想要匹配的术语。所以只需在你的匹配器中用iPhone
交换iemobile
,你就可以了!
正如评论中所述:同时查看if(navigator.userAgent.match(/Windows Phone/i)){
alert('Is a windows phone!');
}
if(navigator.userAgent.match(/iemobile/i)){
alert('Is some mobile IE browser!')
}
// and probably less common, but still useful:
if(navigator.userAgent.match(/WPDesktop/i)){
alert('It is a windows phone in desktop mode!')
}
将为您提供更广泛的检测到的微软移动操作系统。
e.g:
{{1}}
答案 1 :(得分:19)
Lumia 920 WPhone 8,桌面模式
Mozilla / 5.0(兼容; MSIE 10.0; Windows NT 6.2; Trident / 6.0; ARM; Touch; WPDesktop)
Lumia 920 WPhone 8
Mozilla / 5.0(兼容; MSIE 10.0; Windows Phone 8.0; Trident / 6.0; IEMobile / 10.0; ARM; Touch;诺基亚; Lumia 920)
Lumia 820 WPhone 8
Mozilla / 5.0(兼容; MSIE 10.0; Windows Phone 8.0; Trident / 6.0; IEMobile / 10.0; ARM;触摸;诺基亚; Lumia 820)
Lumia 630 WPhone 8
Mozilla / 5.0(Windows Phone 8.1; ARM; Trident / 7.0; Touch; rv:11.0; IEMobile / 11.0;诺基亚; id313-3),如Gecko
Lumia 630 WPhone 8,桌面模式
Mozilla / 5.0(Windows NT 6.2; ARM; Trident / 7.0;触摸; rv:11.0; WPDesktop;诺基亚; id313-3),如Gecko
Lumia 800 WPhone 7.5
Mozilla / 5.0(兼容; MSIE 9.0; Windows Phone OS 7.5; Trident / 5.0; IEMobile / 9.0;诺基亚; Lumia 800)
Lumia 900
Mozilla / 5.0(兼容; MSIE 9.0; Windows Phone OS 7.5; Trident / 5.0; IEMobile / 9.0;诺基亚; Lumia 900)
WP7.5 IEMobile9桌面模式
Mozilla / 5.0(兼容; MSIE 9.0; Windows NT 6.1; Trident / 5.0; XBLWP7; ZuneWP7)
答案 2 :(得分:2)
<强> Working Fiddle for Windows Phone IE 强>
if(navigator.userAgent.match(/iemobile/i))
{
alert('IE is Issue Explorer');
}
答案 3 :(得分:-1)
function isIEMobile() {
var regExp = new RegExp("IEMobile", "i");
return navigator.userAgent.match(regExp);
}