繁体   English   中英

通过Mobile访问时加载Mobile Version,否则加载Desktop Version

[英]Load Mobile Version when visited with Mobile otherwise load Desktop Version

有人能解释我如何调用手机时只能调用网站的移动版本,而当我访问大于500px的所有内容时如何称呼网站的桌面版本吗?

我分别创建了一个移动网站和一个桌面网站。 是否可以使用jQuery检查宽度,然后调用移动版或桌面版?

我这样尝试过

在我的桌面版本上:

<link rel="alternate" media="only screen and (max-width: 500px)" href="../FolderPath/index.html" >

在我的移动版上:

<link rel="canonical" href="../FolderPath/index.html">

但我认为我完全错了。

希望有人可以帮助我,在此先感谢:)

如果屏幕尺寸小于500像素,则可以使用JavaScript检测屏幕尺寸并将用户重定向到移动网站

 <script type="text/javascript">
    if (screen.width <= 500) {
        document.location = "mobile/index.html";
    }
 </script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM