【发布时间】:2014-02-01 12:29:11
【问题描述】:
我正在尝试使用此处提供的解决方案Meta viewport ONLY for phones? 仅在手机上生成元视口标签,我正在将脚本添加到文档的 head 部分,但它没有生成,我得到了控制台上出现“SyntaxError: Expected token ')' 错误。
这是我正在使用的脚本:
<script type="text/javascript">
$(document).ready(function(){
if(navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)) {
document.write('<meta name='viewport' content='width=device-width, user-scalable=no'>');
}
});
</script>
【问题讨论】:
标签: javascript html viewport