-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobile.html
183 lines (173 loc) · 4.54 KB
/
mobile.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<meta charset="utf-8">
<title>Mobile</title>
<script type="text/javascript">
//设置字体大小
var _minWinSize = Math.min(/*window.screen.availWidth,*/window.screen.availHeight,window.innerWidth,window.innerHeight,document.documentElement.clientWidth);
var _minFontSize = Math.min(625*(_minWinSize/640)/0.859, 625);
document.documentElement.style.fontSize = _minFontSize.toFixed(0)+'%';
</script>
<style type="text/css">
html,body,.container {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
.container {
position: relative;
overflow: auto;
overflow-y: scroll;
font-size: 0.25rem;
height: 150%;
}
#log {
height: 150%;
width: 150%;
}
#input {
position: fixed;
left: 0;
right: 0;
bottom: 0;
width: 100%;
}
.px30 {
height: 30px;
background: red;
}
.px5 {
height: 3px;
border: 1px solid green;
}
#input {
background: blue;
height: 50px;
}
#dpi {
width: 1in;
height: 1in;
position: absolute;
}
</style>
</head>
<body>
<div id="dpi"></div>
<div class="container" id="container">
<div id="px30"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="log">
</div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px5"></div>
<div id="px30"></div>
</div>
<input id="input" />
<script type="text/javascript">
function on(dom, name, fn, capture) {
dom.addEventListener(name, fn, capture);
}
function $(selector) {
return document.querySelector(selector);
}
function log(msg) {
if(!log.ready) {
log.msg = (log.msg||'') + msg + '<br/>';
} else {
$('#log').innerHTML += msg + '<br/>';
}
}
on(window, 'load', function() {
$('#log').innerHTML = log.msg;
delete log.msg;
log.ready = true;
log('onload');
});
</script>
<script type="text/javascript">
function backTest() {
history.pushState('title', {}, '#pop');
window.onpopstate=function(e) {
log('trigger by onpopstate() after pushState(): ' + location.href);
}
location.hash = "#hash";
window.onhashchange=function(e) {
log('trigger by onhashchange() after hash=(): ' + location.href);
}
}
backTest();
on(window, 'load', backTest);
function screenRoll() {
window.screen.lockOrientation =
window.screen.lockOrientation||
window.screen.webkitLockOrientation||
window.screen.oLockOrientation||
window.screen.msLockOrientation;
window.screen.unlockOrientation =
window.screen.unlockOrientation||
window.screen.webkitUnlockOrientation||
window.screen.oUnlockOrientation||
window.screen.msUnlockOrientation;
window.screen.lockOrientation &&
window.screen.lockOrientation(["portrait-primary","portrait-secondary"]);
log('test lock orientation');
setTimeout(function() {
window.screen.unlockOrientation &&
window.screen.unlockOrientation();
log('test unlock orientation');
}, 2000);
}
on(window, 'load', screenRoll);
//获取工具栏高度
function getOverlapHeight() {
var sh = screen.availHeight;
var wh = window.innerHeight;
var dpr = window.devicePixelRatio || 1;
if(sh / dpr >= wh) {
sh /= dpr;
}
return sh - wh;
}
log('<hr/>');
log('screen.x: '+(window.screenX||window.screenLeft));
log('screen.y: '+(window.screenY||window.screenTop));
log('screen.w: '+screen.availWidth);
log('screen.h: '+screen.availHeight);
log('window.ow: '+window.outerWidth);
log('window.oh: '+window.outerHeight);
log('window.iw: '+window.innerWidth);
log('window.ih: '+window.innerHeight);
log('document.ow: '+$('html').offsetWidth);
log('document.oh: '+$('html').offsetHeight);
log('document.cw: '+$('html').clientWidth);
log('document.ch: '+$('html').clientHeight);
log('body.ow: '+$('body').offsetWidth);
log('body.oh: '+$('body').offsetHeight);
log('body.cw: '+$('body').clientWidth);
log('body.ch: '+$('body').clientHeight);
log('dpr: '+window.devicePixelRatio);
log('ovh: '+getOverlapHeight());
log('FileReader,-webkit: '+typeof(window.FileReader)+','+typeof(window.webkitFileReader));
log('Worker,-webkit: '+typeof(window.Worker)+','+typeof(window.webkitWorker));
log('ArrayBuffer,-webkit: '+typeof(window.ArrayBuffer)+','+typeof(window.webkitArrayBuffer));
log('Uint8Array,-webkit: '+typeof(window.Uint8Array)+','+typeof(window.webkitUint8Array));
log('<hr/>');
$('#dpi').parentElement.removeChild($('#dpi'));
</script>
</body>
</html>