如果我有重定向,如何让移动用户查看我网站的非移动版本?
利用 http://detectmobilebrowser.com/ 上找到的经典 ASP 代码,我可以将移动浏览器自动重定向到更多内容我的网站的精益和优化的移动版本。
但是,如果移动用户更愿意查看完整的网站,我可以在页脚中提供一个链接,将他们带到那里。不幸的是,当他们返回主站点时,移动检测脚本会启动并再次重定向他们。
我该如何阻止这种情况发生?我的第一个想法是使用 cookie,但我不熟悉所涉及的过程。
Utilizing the classic ASP code found on http://detectmobilebrowser.com/ I have mobile browsers being automatically redirected to the much more lean and optimized mobile version of my site.
However, if a mobile user would rather view the full site, I have a link in the footer to take them there. Unfortunately, when they go back to the main site the mobile detect script kicks in and redirects them again.
How do I stop this from happening? My first thought was using a cookie, but I'm not familiar with the process involved.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在移动登陆页面上,当用户单击“继续访问桌面”链接时,服务器会设置一个 cookie 来标记用户想要查看桌面站点。然后,对于所有请求,如果 cookie 存在,服务器就会让请求发送到桌面站点。否则重定向到移动网站。
示例代码在这里:
http://msdn.microsoft.com/en-us/magazine/jj553508.aspx
On the mobile landing page, when the user clicks "continue to the desktop" link, the server set a cookie to flag the user wants to see the desktop site. Then for all the request, if the cookie is there, the server just let the request go the the desktop site. Otherwise redirect to the mobile site.
Sample code is here:
http://msdn.microsoft.com/en-us/magazine/jj553508.aspx
我使用查询字符串(例如default.asp?redirect=0)执行此操作,然后使用if-else,我仅在没有redirect=0时运行deection脚本
i do it with query string such as default.asp?redirect=0 then with if-else i only run dedection script when there is no redirect=0