Regarding window.innerWidth
and document.documentElement.clientWidth
,
Webkit (Chrome / Safari) claims innerWidth
is smaller than clientWidth
.
Trident and Presto claim innerWidth
is bigger than clientWidth
.
Gecko claims innerWidth
is the same size as clientWidth
.
What is the correct behavior stated by W3C (or silimar "authority")?
Test Script (on JSFiddle) (on GoogleHost):
setInterval(function() {
var inner_w = window.innerWidth;
var inner_h = window.innerHeight;
var client_w = document.documentElement.clientWidth;
var client_h = document.documentElement.clientHeight;
var debug_msg = "inner: " + inner_w + "-" + inner_h + "<br>client: " + client_w + "-" + client_h;
document.getElementById("d").innerHTML = debug_msg;
document.title = debug_msg;
document.body.style.background = (client_w === inner_w && client_h === inner_h ? "green" : "red");
}, 60);
<div id="d"></div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…