简体   繁体   English

如何在Windows Phone中重定向页面

[英]How to redirect page in Windows Phone

I'm developing a web page in jQuery Mobile and I'm redirecting the user to another page through window.location.replace('#page1') which works fine on Android and iOS but not on Windows Phone 7 - the URL is updated but doesn't changes the page. 我正在jQuery Mobile中开发网页,并通过window.location.replace('#page1')将用户重定向到另一个页面,该页面在Android和iOS上运行良好,但在Windows Phone 7上不行-URL已更新但不会更改页面。

I'm using window.location.replace instead of window.location.assign or location.hash because I'm interested in preventing the user from using the back button. 我使用window.location.replace而不是window.location.assignlocation.hash因为我有兴趣防止用户使用后退按钮。

I had the exact same problem but solved it by changing the script to 我遇到了完全相同的问题,但通过将脚本更改为

$.mobile.changePage(#pageID)

Worked great for me, good luck! 对我来说很棒,祝您好运!

just tested this on a lumia900, window.location.replace('#page1') should work fine, and it also fires the onhashchange event i assume drives the change in screen etc... 刚刚在lumia900上进行了测试,window.location.replace('#page1')应该可以正常工作,并且还会触发onhashchange事件,我认为这会推动屏幕的变化等。

so my guess, without diving into jquery mobile or setting up a mock site is that either your URL hash is incorrect and it is just working through some dumb luck some of the time 因此,我的猜测是,如果没有深入研究jquery mobile或设置模拟站点,则可能是您的URL哈希不正确,并且在某些时候它只是通过了一些愚蠢的运气

OR 要么

jquery mobile has a bug in it some where that is causing havoc on your setup jQuery mobile中有一个错误,该错误会在您的设置上造成破坏

here's the test page i used: http://jsbin.com/eqelit/1/edit 这是我使用的测试页: http : //jsbin.com/eqelit/1/edit

尝试使用window.location.href="www.google.com"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM