There seems to be some strange behaviour when trying to get the
scrollHeight and scrollTop of an iframe in IE6.
I have tried several ways of getting these values when the iframe is
written into the html. The following return the correct values in IE6,
where the iframe's id is 'f':
f.document.body .scrollHeight
f.document.body .scrollTop
window.frames['f'].document.body. scrollHeight
window.frames['f'].document.body. scrollTop
document.frames ('f').document. body.scrollHeig ht
document.frames ('f').document. body.scrollTop
The following give a strange value for scrollHeight (definitely not
the length of the contents of the iframe) and scrollTop is always 0:
document.getEle mentById('f').d ocument.body.sc rollHeight
document.getEle mentById('f').d ocument.body.sc rollTop
document.all.f. document.body.s crollHeight
document.all.f. document.body.s crollTop
When I dynamically create the iframe, using myFrame =
document.create Element('IFRAME '), I get the same strange values as
above when I do this:
myFrame.documen t.body.scrollHe ight
myFrame.documen t.body.scrollTo p
However this works as correctly in Opera 7. I find this all very
confusing. Can anybody shed light onto how I might get the correct
values in IE6 when using the createElement() method?