gpt4 book ai didi

javascript - 在其他元素中,phonegap 事件 api 不起作用(例如)后退按钮

转载 作者:行者123 更新时间:2023-11-28 09:24:57 25 4
gpt4 key购买 nike

document.addEventListener("deviceready", function () {
document.addEventListener("backbutton", function() {
alert("hello");
});
});

它正在工作但是

var element = $("#score-screen")[0];
element.addEventListener("deviceready", function() {
element.addEventListener("backbutton", function() {
alert("hello");
});
});

score-screen 是 div id它不工作..请帮助我..请

最佳答案

我认为设备就绪和后退按钮只能在文档上触发。

Phonegap 文档:http://docs.phonegap.com/en/2.3.0/cordova_events_events.md.html#deviceready

This is a very important event that every Cordova application should use.

Cordova consists of two code bases: native and JavaScript. While the native code is loading, a custom loading image is displayed. However, JavaScript is only loaded once the DOM loads. This means your web application could, potentially, call a Cordova JavaScript function before it is loaded.

The Cordova deviceready event fires once Cordova has fully loaded. After the device has fired, you can safely make calls to Cordova function.

Typically, you will want to attach an event listener with document.addEventListener once the HTML document's DOM has loaded.

This event behaves differently from others in that any event handler registered after the event has been fired will have its callback function called immediately.

关于javascript - 在其他元素中,phonegap 事件 api 不起作用(例如)后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14518451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com