在不同瀏覽器都實(shí)用的 JavaScript 方案應(yīng)該是這樣的:
var w=window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h=window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
可以參考http://www.w3school.com.cn/js/js_window.asp的講解