1

I'm looking for at solution 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);
clarkk
  • 27,151
  • 72
  • 200
  • 340
  • possible duplicate of [document.body.scrollTop is always 0 in IE even when scrolling](http://stackoverflow.com/questions/2717252/document-body-scrolltop-is-always-0-in-ie-even-when-scrolling) – Caspar Kleijne Apr 24 '11 at 07:00
  • but it works fine in ie if you remove the doctype tag? – clarkk Apr 24 '11 at 07:03

1 Answers1

1

I think these are the two alternatives:

var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
Halcyon
  • 57,230
  • 10
  • 89
  • 128