当我看到这段代码时,我有点疑惑:
// Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
...
// Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
$(document).height();
和 $(window).height();
有什么区别?
最佳答案
Window 是顶级客户端对象,其中包含文档。这个 jsFiddle 显示 $(window).height()
和 $(document).height()
返回相同的值:http://jsfiddle.net/jackrugile/5xSuv/
窗口是视口(viewport)的大小,不包括任何 chrome 或浏览器界面,如果我没记错的话。我相信两者的值将始终相同,除非您在窗口中引用类似 iframe 的内容。
关于javascript - JS "Window"宽高与 "screen"宽高?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6255677/