1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<!DOCTYPE html>
<html>
<head>
<title>Pause Example</title>
<meta http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
>
<script type=
"text/javascript"
charset=
"utf-8"
src=
"cordova.js"
></script>
<script type=
"text/javascript"
charset=
"utf-8"
>
//頁面加載後添加各事件監聽
function
onLoad() {
document.addEventListener(
"deviceready"
, onDeviceReady,
false
);
document.addEventListener(
"resume"
, onResume,
false
);
document.addEventListener(
"pause"
, onPause,
false
);
}
//Cordova加載完畢
function
onDeviceReady() {
alert(
"Cordova加載完畢!"
);
}
//進入後臺
function
onPause() {
console.log(
"應用進入到後臺!"
);
}
//恢復到前臺
function
onResume() {
alert(
"應用回到前臺運行!"
);
}
</script>
</head>
<body onload=
"onLoad()"
>
</body>
</html>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<!DOCTYPE html>
<html>
<head>
<title>Pause Example</title>
<meta http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
>
<script type=
"text/javascript"
charset=
"utf-8"
src=
"cordova.js"
></script>
<script type=
"text/javascript"
charset=
"utf-8"
>
//頁面加載後添加各事件監聽
function
onLoad() {
document.addEventListener(
"deviceready"
, onDeviceReady,
false
);
document.addEventListener(
"resume"
, onResume,
false
);
document.addEventListener(
"pause"
, onPause,
false
);
}
//Cordova加載完畢
function
onDeviceReady() {
console.log(
"Cordova加載完畢!"
);
}
//進入後臺
function
onPause() {
console.log(
"應用進入到後臺!"
);
}
//恢復到前臺
function
onResume() {
console.log(
"應用回到前臺運行!"
);
}
</script>
</head>
<body onload=
"onLoad()"
>
</body>
</html>
|