使用phonegap + jquery mobile加载外部链接,这个history.back不起作用?

时间:2011-11-28 03:24:25

标签: jquery mobile cordova

我使用phonega + jquerymobile开发一个程序。 phonegap以本地页面开始。我需要加载一些外部页面。所以,我用

$.mobile.changePage("some url");

加载外部页面。当外部页面中的用户导航时,不能使用history.back();来返回上一页。程序崩溃并退出。
顺便说一下,我用logcat找到了一个ERR消息:

E/Web Console(334): SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent. at     
file:///android_asset/www/js/jquery.mobile-1.0.js:3536
In line 3536 of jquery.mobile-1.0.js: history.replaceState( state, document.title, href ); 

1 个答案:

答案 0 :(得分:0)

我有一个黑客。我找不到其他方法来解决我的应用程序中的这个问题,所以我把它包装好了:

history.replaceState( state, document.title, href );

try{history.replaceState( state, document.title, href );}catch(e){}

这会丢弃错误,应用程序仍然有效。使用它是你自己的危险。