[英]Load Mobile Version when visited with Mobile otherwise load Desktop Version
can someone exlpain me how i can call my Mobile Version of a Website only when i visit by Phone and my Desktop Version of the Website when i visit everything that's bigger then 500px? 有人能解释我如何调用手机时只能调用网站的移动版本,而当我访问大于500px的所有内容时如何称呼网站的桌面版本吗?
I have created a Mobile Website and a Desktop Website seperatly. 我分别创建了一个移动网站和一个桌面网站。 Is it possible to check the width with jQuery and then call either the Mobile or Desktop Version?
是否可以使用jQuery检查宽度,然后调用移动版或桌面版?
i tried it like this 我这样尝试过
on my Desktop Version: 在我的桌面版本上:
<link rel="alternate" media="only screen and (max-width: 500px)" href="../FolderPath/index.html" >
on my Mobile Version: 在我的移动版上:
<link rel="canonical" href="../FolderPath/index.html">
but i think i'm totally wrong. 但我认为我完全错了。
hope someone can help me, thanks in advance :) 希望有人可以帮助我,在此先感谢:)
You can detect screen size with JavaScript and redirect user to mobile site if screen size is less than 500px 如果屏幕尺寸小于500像素,则可以使用JavaScript检测屏幕尺寸并将用户重定向到移动网站
<script type="text/javascript">
if (screen.width <= 500) {
document.location = "mobile/index.html";
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.