admin管理员组文章数量:1336663
A website I'm making has a separate set of files for mobile view due to the html layout being difficult to make responsive.
I'm looking for code that will detect if the user is on a mobile, then redirect them to the m.website domain instead.
I found this:
<script type="text/javascript">
if (screen.width <= 699) {
document.location = "YOUR-MOBILE-SITE";
}
</script>
But on most mobile devices, there is an option to view the desktop version of websites, but it looks like this javascript will ignore that and keep redirecting anyway.
Is there a better way of doing this?
A website I'm making has a separate set of files for mobile view due to the html layout being difficult to make responsive.
I'm looking for code that will detect if the user is on a mobile, then redirect them to the m.website. domain instead.
I found this:
<script type="text/javascript">
if (screen.width <= 699) {
document.location = "YOUR-MOBILE-SITE.";
}
</script>
But on most mobile devices, there is an option to view the desktop version of websites, but it looks like this javascript will ignore that and keep redirecting anyway.
Is there a better way of doing this?
Share Improve this question asked Jan 9, 2015 at 10:07 HippoDuckHippoDuck 2,2044 gold badges31 silver badges51 bronze badges 2- possible duplicate of Mobile page redirect issue – Hacketo Commented Jan 9, 2015 at 10:11
- @Hacketo Thanks, I did search but didn't find that post. - Edit: No that's a different issue in the post. Although the answer is useful. – HippoDuck Commented Jan 9, 2015 at 10:19
1 Answer
Reset to default 4This is one of the best module available online,i used the same for my website,it is supported by a major number of mobile devices,many developers has contributed to this repository,might be helpful to you,also it caters for redirection to website through mobile version
Redirection to Mobile Site
本文标签: javascriptDetect and redirect to mobile siteStack Overflow
版权声明:本文标题:javascript - Detect and redirect to mobile site - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742322785a2453125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论