<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>Webview Example</title>
<script src="js/mui.min.js"></script>
<script type="text/javascript">
var nw=null;
// H5 plus事件处理
function plusReady(){
}
if(window.plus){
plusReady();
}else{
document.addEventListener('plusready', plusReady, false);
}
// 监听Webview窗口关闭事件
function eventTest(){
var self = plus.webview.currentWebview();
nw = plus.webview.create('http://lewee.net/', '乐微', {
top: '40px',
bottom: 0
});
self.append(nw);
}
var first = null;
mui.back = function() {
//首次按键,提示‘再按一次退出应用’
if (!first) {
first = new Date().getTime();
mui.toast("再按一次退出应用"); //给出提示
nw.close()
setTimeout(function() {
//1s中后清除
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1000) {
//如果两次按下的时间小于1s,
plus.runtime.quit(); //那么就退出app
}
}
};
</script>
</head>
<body>
Webview窗口关闭事件
<button onclick="eventTest()">start</button>
<button onclick="nw.close()">close</button>
</body>
</html>