在 Blackberry playbook 上,正常 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", []);
};
有什么线索吗?
最佳答案
除了覆盖 window.history.back,您可以编写一个通用的返回函数,它可以根据定义的函数执行操作:
function goBack(){
if (typeof (navigator.app) !== "undefined") {
navigator.app.backHistory();
} else {
window.history.back();
}
}
我不确定这是否能回答您的问题,但我一直在使用这种方法在移动设备和桌面浏览器上进行测试。
关于cordova - Phonegap navigator.app.backHistory/window.history.back 不适用于 Blackberry Playbook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9156084/