Events---cordova事件
来源:互联网 发布:黑暗网络泄露图片 编辑:程序博客网 时间:2024/05/22 23:22
There are various events provided by cordova to be used by the application. The application code could add listeners for these events. For example:
cordava提供事件:上代码
HTML File
<!DOCTYPE html><html> <head> <title>Device Ready Example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8" src="example.js"></script> </head> <body onload="onLoad()"> </body></html>
这是html调用了onload
既然说事件 可能有回调,写在了js里面
JS File
// example.js file// Wait for device API libraries to load//function onLoad() { document.addEventListener("deviceready", onDeviceReady, false);}// device APIs are available//function onDeviceReady() { document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); document.addEventListener("menubutton", onMenuKeyDown, false); // Add similar listeners for other events}function onPause() { // Handle the pause event}function onResume() { // Handle the resume event}function onMenuKeyDown() { // Handle the menubutton event}// Add similar event handlers for other events
onDeviceReady
Note: Applications typically should use document.addEventListener
to attach an event listener once the deviceready
addEventListener
加上监听
The following table lists the cordova events and the supported platforms:事件支持机子:看来有些不支持回调啊,有哪些事件不支持那些机子呢:
Supported Platforms/
Eventsandroid blackberry10 ios Windows Phone 8 Windows
deviceready
The deviceready event fires when Cordova is fully loaded. This event is essential to any application. It signals that Cordova's device APIs have loaded and are ready to access.
deviceready 是最早的一个监听,Cordova 一旦加载完毕就出发此回调。标志Cordova api完全加载,可以利用。刨出来的坑终于可以拉屎了。
Cordova consists of two code bases: native and JavaScript. While the native code loads, a custom loading image displays. However, JavaScript only loads once the DOM loads. This means the web app may potentially call a Cordova JavaScript function before the corresponding native code becomes available.
Cordova :js native哪个会先调用呢,js方法可以在native调用回来之前调用。
The deviceready
event fires once Cordova has fully loaded. Once the event fires, you can safely make calls to Cordova APIs. Applications typically attach an event listener with document.addEventListener
once the HTML document's DOM has loaded.
Dom一旦加载 就可以用deviceready
起作用了
The deviceready
event behaves somewhat differently from others. Any event handler registered after the deviceready
event fires has its callback function called immediately.
此句强调了deviceready
的江湖地位,一旦出发了deviceready
就立马执行他的回调实现
一瞥:
Quick Example
document.addEventListener("deviceready", onDeviceReady, false);function onDeviceReady() { // Now safe to use device API deviceready触发立马执行}
- Events---cordova事件
- cordova学习四:事件Events
- events 事件
- Cordova 事件
- cordova 事件
- Javascript events 事件大全
- Events(事件)
- MySQL事件 Events
- IOS Sent Events 事件
- jqGrid Events事件
- IOS Sent Events 事件
- Jquery事件(Events)介绍
- PhoneGap事件Events
- IOS Sent Events 事件
- IOS Sent Events 事件
- Input Events(输入事件)
- node events事件循环
- nodeJS之事件events
- UVA
- JVM高级特性与实践(八):虚拟机的类加载机制
- 使用Viewpager Indicator实现图片无限轮播
- PAT乙级 1032. 挖掘机技术哪家强(20)
- get请求直接通过浏览器发请求传数组或者list到后台
- Events---cordova事件
- 写一个shell脚本利用wget抓取股票历史数据
- UVA 10891 Game of Sum(区间DP)
- 继承与菱形继承
- Java 异常
- Linux 修改mysql 表名不区分大小写
- jsp中的<%@ ...%>
- [Eclipse]
- javaweb中运用fileupload上传文件