读书人

JQuery获取元素文档大小、偏移跟位置和

发布时间: 2012-10-11 10:16:10 作者: rapoo

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});


引自:http://www.jb51.net/article/21812.htm
http://blog.csdn.net/lee576/archive/2008/12/16/3528041.aspx

读书人网 >Web前端

热点推荐