如何重定向到移动网站但保留井号标签? [英] How do I redirect to a mobile site but keep the hash tag?

查看:181
本文介绍了如何重定向到移动网站但保留井号标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找它,以便当用户加载我们的页面时检查它是否在移动设备上,然后将其重定向到我们网站的移动版本,但保留原始哈希值从他们遵循的链接中添加标签.我尝试用javascript中的hash标签设置新位置,它在Chrome浏览器中有效,但在Safari中不起作用.我读过,这只是Safari所做的.有什么解决办法吗?

I'm looking to have it so that when a user loads our page it checks to see if they're on a mobile device and then it'll redirect them to a mobile version of our site, but keep the original hash tag from the link they followed. I've tried setting the new location with the hash tag in javascript and it works in Chrome but doesn't work in Safari. I've read that this is just something Safari does. Is there any work around to this?

推荐答案

您应该转义'#'符号,然后一切正常

You should escape '#' symbol and everything would be OK

这篇关于如何重定向到移动网站但保留井号标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆