【问题标题】:use phonegap+jquery mobile load the external link,this history.back not work?使用phonegap+jquery 移动加载外部链接,这个history.back 不起作用?
【发布时间】:2012-11-14 08:25:16
【问题描述】:

我使用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 ); 

【问题讨论】:

    标签: jquery mobile cordova


    【解决方案1】:

    我有一个技巧。我发现没有其他方法可以在我的应用程序中解决此问题,因此我将其打包:

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

    进入

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

    这会丢弃错误,并且应用程序仍然正常运行。使用它,后果自负。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多