JavaScript重定向到移动URL#锚点链接不受请求支持



AM在下面使用JS函数,以将索引页面重定向到另一个页面,如果移动屏幕宽度小于600 px;
锚定链接重定向到索引页面并从其他页面启动的问题没有将任何锚链接传递给用于重定向的新请求的URL。
例如: index.html重定向到mobIndex.html现在: index.html #andar-link 仅将重定向到mobIndex.html #andor不包括。。

    <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>

有人以前有这个问题吗?谢谢。

谢谢您的任何帮助...实际添加 +window.location.hash;到请求的URL,以此解决问题:

window.location = "http://mywebsite.com/mobindex.html" +window.location.hash;