【问题标题】:Mobil Version redirect移动版重定向
【发布时间】:2018-11-30 21:36:28
【问题描述】:

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

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

有什么帮助吗? 谢谢!

【问题讨论】:

    标签: javascript redirect mobile


    【解决方案1】:

    尝试使用window.innerWidthwindow.outerWidth

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

    【讨论】:

    • 非常感谢nicktu12,您能详细说明一下吗?不太熟悉 window.innerWidth 或 window.outerWidth 将如何提供帮助。我认为更改交易窗口类型的大小更重要...在此先感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    相关资源
    最近更新 更多