开发者

scrollTop and 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜