【问题标题】:Phonegap navigator.app.backHistory / window.history.back not working on Blackberry PlaybookPhonegap navigator.app.backHistory / window.history.back 在黑莓 Playbook 上不起作用
【发布时间】:2012-02-06 05:54:10
【问题描述】:

在黑莓的剧本中,正常的 window.history.back 不起作用。在模拟器上测试....

所以,我在 index.html 中尝试了这个

window.history.back = navigator.app.backHistory;

这将控制Phonegap函数,但在运行时它会抛出一个错误:

"Error: Status=2 Message=Class App cannot be found"

这里是Phonegap(1.4.1)函数:

/**
 * Navigate back in the browser history.
*/
App.prototype.backHistory = function() {
    // window.history.back() behaves oddly on BlackBerry, so use
    // native implementation.
    console.log("in backHistory");
    PhoneGap.exec(null, null, "App", "backHistory", []);
};

有什么线索吗?

【问题讨论】:

    标签: cordova blackberry browser-history blackberry-playbook


    【解决方案1】:

    您可以编写一个通用的后退函数,而不是覆盖 window.history.back,该函数可以根据定义的函数进行操作:

    function goBack(){
        if (typeof (navigator.app) !== "undefined") {
            navigator.app.backHistory();
        } else {
            window.history.back();
        }
    }
    

    我不确定这是否能回答您的问题,但我一直在使用这种方法在移动设备和桌面浏览器上启用测试。

    【讨论】:

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