0

我正在尝试自定义一个 cargo2 模板,并且无法访问 html 头,只有 body 和 css。但是,我可以将元标记添加到 head 中。我正在尝试根据屏幕尺寸重定向到移动版本,这是我迄今为止使用的,但它不起作用,因为我无权访问 html 头部:

<script type="text/javascript">
<!--
if (screen.width <= 700) {
window.location = "http://www.mobile-site.com";
}
//-->
</script>

有什么帮助吗?谢谢!

4

1 回答 1

0

尝试使用window.innerWidthwindow.outerWidth

查看更多:https ://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth

于 2018-11-30T21:39:41.950 回答