Today, adjust the pop-up layer, encountered a small problem: get scrolltop value?
On the Internet to see some of the high way to get the page was rolled, document.body.scrollTop in IE FF is 0, the strange is in Chrome can.
I guess FF to be closer to IE, I used the FF 13.0.1, can be used in the previous version, this skip ...
The code is as follows |
Copy Code |
S + + "Web page is rolled high (FF):" + document.body.scrollTop; S + + "Web page is rolled high (ie):" + document.documentElement.scrollTop; |
Code fragment:
code is as follows |
copy code |
var h = Document.documentelement.clientheight;//js Get window height var t = document.body.scrolltop| | Document.documentelement.scrolltop;//js gets the high var h2 = $ (' # ' +id) that the page was rolled over. Height ();//jq get the height of the pop-up layer $ (' # ' +id). CSS (' Top ', (H-H2)/2+t);//jq to CSS plus top value |