【发布时间】:2018-09-05 00:53:33
【问题描述】:
如果手机屏幕宽度小于 600 像素,我正在使用下面的 JS 函数将索引页面重定向到另一个页面;
锚链接重定向到索引页面并从其他页面启动的问题没有将任何锚链接传递到用于重定向的新请求 url。
例如: Index.html 重定向到mobindex.html
现在: Index.html#anchor-link 仅重定向到 mobindex.html#anchor 不被包含。
<script>
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent) ) {
if(screen.width >= 600){
// Stay on desktop website
} else {
window.location = "http://mywebsite.com/mobindex.html";
}
}
</script>
以前有没有人遇到过这个问题,有什么可能的解决方法? 谢谢。
【问题讨论】:
标签: javascript mobile url-redirection http-redirect