我使用此代码
<script type="text/javascript">
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/Windows Phone OS|Windows CE|Windows Mobile|IEMobile|Windows Phone OS 7|Windows Phone 8/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
</script>
我想检测设备是否可移动。如果是我重定向到页面,否则我锁定访问
<script type="text/javascript">
if( isMobile.any() ) alert('Mobile');
else {
alert('No Mobile');
location.href = 'block.html';
};
</script>
但是使用Windows Phone这不起作用!所有其他设备工作正常。请有人帮帮我?