Doctype strict and IE6 - monitoring scrolling

T

Tony T

I'm not a regular here - strictly an amateur web developer - but I've got so
frustrated I'd really appreciate any help anyone can give. I'm working on a
PC platform with Win ME.

I'm developing a new set of web pages, using html4.01 strict with css2
stylesheets. As part of the design, I need to be able to monitor and measure
the vertical scrolling of my document in the viewport. I have got this to
work with up-to-date Netscape and Opera browsers using window.pageYOffset,
but good ol' IE6 has me stumped. My actual pages validate for both html and
css, and I've got other arrangements for earlier and other browsers, so it's
just IE6 that's the problem. Please take a look at these stripped-down
examples (also valid) -

http://rnetworks2002.users.btopenworld.com/scrolltest_nodoc.html and
http://rnetworks2002.users.btopenworld.com/scrolltest_strict.html

You'll see that in the first case, with no DOCTYPE declaration,
document.body.scrollTop returns a value according to the scroll position. In
the second case, with the DOCTYPE declaration, doc.body.scrollTop no longer
varies.

I need the strict doctype for the pages to render correctly with my
stylesheet, so I can't just get rid of the doctype, nor do the pages or
doc.body.scrollTop work if I change the DOCTYPE to transitional (with or
without dtd url). Dropping the url from the strict DOCTYPE doesn't affect
the behaviour of document.body.scrollTop.

I've tried my usual resources (as well as a search here) for ideas, but
without success. So, please can anyone tell me either how to get scrollTop
to work with a strict doctype declaration, or some other way to monitor
scrolling which works in IE6 and html4.01 strict.

Thanks for any help.
 
M

Martin Honnen

Tony T wrote:

I'm developing a new set of web pages, using html4.01 strict with css2
stylesheets. As part of the design, I need to be able to monitor and measure
the vertical scrolling of my document in the viewport. I have got this to
work with up-to-date Netscape and Opera browsers using window.pageYOffset,
but good ol' IE6 has me stumped.

You are looking for
document.documentElement.scrollTop/scrollLeft
for IE6 in strict rendering mode (check
if (document.compatMode && document.compatMode != 'BackCompat') {
... document.documentElement.scrollTop...
}
 
T

Tony T

Martin Honnen said:
Tony T wrote:



You are looking for
document.documentElement.scrollTop/scrollLeft
for IE6 in strict rendering mode (check
if (document.compatMode && document.compatMode != 'BackCompat') {
... document.documentElement.scrollTop...
}

Martin - thanks. You're a star!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top