JQuery获取元素文档大小、偏移和位置和滚动条位置的方法集合
因为浏览器的兼容问题,如果使用javascript获取这些数值是一个相当痛苦的过程。好在JQuery提供了简单优雅,并且兼容的解决方法。
获取浏览器和页面文档的宽度和高度
//request data for centeringvar windowWidth = document.documentElement.clientWidth;var windowHeight = document.documentElement.clientHeight;var popupHeight = $("#popupContact").height();var popupWidth = $("#popupContact").width();//centering$("#popupContact").css({ "position": "absolute", "top": windowHeight/2-popupHeight/2, "left": windowWidth/2-popupWidth/2});