为了检测我正在使用以下脚本的用户代理。 window phone 似乎忽略了 meta viewport 标签。让其他人遇到同样的问题。基本上我想在所有移动设备上缩小页面。
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 正在工作我通过警报检查了它,但视口(viewport)元及其属性不起作用。尽管我添加了 initial-scale=0.25
但我没有得到缩小页面除 window phone 外,所有移动设备都符合预期。
最佳答案
对于 IE 10 你可以试试这个
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
并且 initial-scale 仅适用于 IE 的 portrait 模式,请检查 compactibality in quirksmode
关于javascript - meta viewport 标签在 window phone IE 浏览器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25244731/