forked from dcloudio/casecode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.html
89 lines (85 loc) · 2.81 KB
/
browser.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>36氪 - 内置浏览器</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" href="css/app.css" />
<style>
#loading {
width: 30px;
}
#loading .mui-spinner {
position: absolute;
top: 12px;
}
</style>
</head>
<body class="kr-browser">
<div class="kr-browser-bar mui-bar mui-bar-standard mui-bar-footer">
<div class="mui-pull-left">
<a id="historyBack" class="mui-icon mui-icon-arrowleft"> </a>
<a id="historyForward" class="mui-icon mui-icon-arrowright"> </a>
<a id="loading" class="mui-icon">
<span class="mui-spinner"></span>
</a>
<a id="reload" class="mui-icon mui-icon-reload mui-hidden"> </a>
</div>
<div class="mui-pull-right">
<button id="back" type="button" class="mui-action-back mui-btn">关闭</button>
</div>
</div>
<script type="text/javascript" charset="UTF-8" src="js/mui.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="js/app.js"></script>
<script>
(function($) {
$.plusReady(function() {
var browser = plus.webview.getWebviewById('browser');
mui.init({
beforeback: function() {
browser.clear();
}
});
document.getElementById("historyBack").addEventListener('tap', function() {
browser.canBack(function(e) {
if (e.canBack) {
browser.evalJS('window.history.back()');
}
});
return false;
});
document.getElementById("historyForward").addEventListener('tap', function() {
browser.canForward(function(e) {
if (e.canForward) {
browser.evalJS('window.history.forward()');
}
});
return false;
});
document.getElementById("reload").addEventListener('tap', function() {
reloadClassList.add('mui-hidden');
loadingClassList.remove('mui-hidden');
browser.reload(true);
});
var reloadClassList = document.getElementById("reload").classList;
var loadingClassList = document.getElementById("loading").classList;
document.addEventListener('mui.view.beforeshow', function(e) {
if (plus.networkinfo.getCurrentType() === plus.networkinfo.CONNECTION_NONE) {
plus.nativeUI.alert('无网络连接!');
} else {
reloadClassList.add('mui-hidden');
loadingClassList.remove('mui-hidden');
}
});
browser && browser.addEventListener('loaded', function() {
reloadClassList.remove('mui-hidden');
loadingClassList.add('mui-hidden');
});
});
})(mui);
</script>
</body>
</html>