Jef*_*eff 6 javascript jquery document window screen
当我看到这段代码时,我想知道一点:
// 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();?
jac*_*ile 11
Window是顶级客户端对象,包含文档.这的jsfiddle表明,无论$(window).height()和$(document).height()返回相同的值:http://jsfiddle.net/jackrugile/5xSuv/
窗口是视口的大小,如果我没有弄错的话,它不包括任何chrome或浏览器界面.我相信两者的值将始终相同,除非您在窗口中引用类似iframe的内容.
$(document).height是视口的内部区域,基本上是从工具栏/网址栏的底部到状态栏/底部滚动条/窗口底部。获取$(window).height窗口的整个高度,包括地址栏和滚动条等。