以检测我正在使用的用户代理。窗口电话似乎忽略了元视区标记。让其他人遇到同样的问题。基本上我想缩小所有移动设备的页面。

if(navigator.userAgent.match(/Android/i)
  || navigator.userAgent.match(/Windows Phone/i)
  || navigator.userAgent.match(/webOS/i)
  || navigator.userAgent.match(/iPhone/i)
  || navigator.userAgent.match(/iPod/i)
  || navigator.userAgent.match(/BlackBerry/i)
  || navigator.userAgent.match(/iemobile/i)) {
    document.write('<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=0.25" />');

}

也尝试过:
|| navigator.userAgent.match(/Windows Phone/i)

navigator.userAgent正在工作我通过alert检查了它,但是viewport meta及其属性不工作。我没有得到缩小页面,虽然我已经添加了初始比例=0.25
除了视窗电话,所有的移动设备都能如期而至。

最佳答案

对于IE 10你可以试试这个

if (navigator.userAgent.match(/IEMobile\/10\.0/)) {

并且初始比例仅在IE的纵向模式下工作检查compactibality in quirksmode

09-17 15:02
查看更多