开发者

scrollTop and doctype

开发者 https://www.devze.com 2023-02-28 03:24 出处:网络
I\'m looking for at so开发者_如何转开发lution to make document.body.scrollTop return the right values when using a doctype

I'm looking for at so开发者_如何转开发lution to make document.body.scrollTop return the right values when using a doctype

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

now this only works with chrome and not in ff and ie

alert('scrollTop = '+document.body.scrollTop);


I think these are the two alternatives:

var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
0

精彩评论

暂无评论...
验证码 换一张
取 消