我正試圖在PhoneGap Documentation和Override Android Backbutton behavior only works on the first page with PhoneGap的幫助下使用後退按鈕。「[undefined]不是函數」在處理PhoneGap中的回退事件時
我的代碼:
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("df");
console.log("PhoneGap Ready!");
document.addEventListener("backbutton", handleBackButton, false);
}
function handleBackButton() {
console.log("Back Button Pressed!");
alert("df");
}
</script>
但我得到這個錯誤:
05-21 16:00:03.248: E/Web Console(1615): TypeError: Result of expression 'PhoneGap.fireDocumentEvent' [undefined] is not a function. at undefined:1
不知道這是否是同樣的問題,但我解決了我的後退按鈕處理問題的活動類中重寫onBackPressed: @Override 公共無效onBackPressed(){ 回報; } – davids
我試過這也是由http://stackoverflow.com/questions/10382634/how-to-prevent-android-from-closing-web-application-when-backbutton-is-pressed link.no聲音 – user1324068
好的,這個答案有點愚蠢,但只是爲了確認,你有沒有鏈接正確的cordova-x.js?我的意思是,你沒有附加iOS,Blackberry等的js,是嗎? – davids