From: Mayayana on
| > Are you saying that IE.document.body.scrollTop
| > does not work in IE8? It should work in all versions
| > from IE4 up. I've never heard of MS breaking any
| > of the DOM functionality. There should be no need
| > to test for IE versions.
|
| My computer:
|
| XP SP3
| VB6
| Internet Explorer 8.0.6001.18702
| IE.Document.body.scrollTop does not work
| IE.Document.documentElement.scrollTop does work.
|

You're doing something wrong. It would break
half of the Web if MS just started dropping support
for exisiting DOM functions. Anything that worked
in IE 4 should work fine in all other versions. And
for the most part what worked in IE4 is sufficient.
(I mean the DOM specifically. It's another issue
if you're trying to do something like script advanced
style properties. Those can vary with IE versions.)


To be certain I just tried it on XP SP3 with IE8.
I tried it with a local webpage, an online webpage,
and with a WB control. It worked fine.

The following VBScript demonstrates it.
Save the text in a .vbs file. Put a large HTML
file on C drive named test1.html. Run the script.
You should see the page move every two seconds.
After the page returns to the top you have 5
seconds to scroll it down by hand to test the
property Get.

'-------- begin script code ----

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = True
IE.navigate2 "C:\test1.html"
Do While IE.ReadyState <> 4
WScript.sleep 100
Loop

IE.document.Body.scrollTop = 500
WScript.sleep 2000
IE.document.Body.scrollTop = 1000
WScript.sleep 2000
IE.document.Body.scrollTop = 10

WScript.sleep 5000

MsgBox IE.document.Body.scrollTop

IE.Quit
Set IE = Nothing

WScript.quit



From: Juergen Thuemmler on
Hi Mike,

> IE.Document.body.scrollTop does not work
> IE.Document.documentElement.scrollTop does work.

I agree (IE 8.0.6001.18702):

Dim SW As SHDocVw.ShellWindows, IE As InternetExplorer, WB As WebBrowser
Set SW = New SHDocVw.ShellWindows
For Each IE In SW
Debug.Print IE.hwnd
Debug.Print IE.document.body.scrollTop '# = 0
Debug.Print IE.document.documentElement.scrollTop '# = correct
IE.document.documentElement.scrollTop = 200 '# works
Debug.Print IE.document.documentElement.scrollTop
Next

Juergen.


From: Juergen Thuemmler on
Hi Mike,

> Debug.Print IE.document.documentElement.scrollTop '# = correct

I've only IE8, but it must work also for IE < IE8. Does it or must I
differentiate regarding the version?

Juergen.


From: Mayayana on
Curiouser and curiouser.....

I just edited your code a bit for clarity. Then I
opened two IEs with a webpage in each. I scrolled
one down a ways. XP SP3 IE v. 8.0.6001.18702

Here's my code:

Private Sub Command1_Click()
Dim SW As SHDocVw.ShellWindows, IE As InternetExplorer
Dim s1 As String
Set SW = New SHDocVw.ShellWindows
On Error Resume Next
For Each IE In SW
s1 = TypeName(IE.Document)
If InStr(1, s1, "html", 1) > 0 Then '--filter out folder windows.
Debug.Print IE.LocationURL
Debug.Print "body: " & IE.Document.body.scrollTop
Debug.Print "DocEl: " & IE.Document.documentElement.scrollTop
IE.Document.documentElement.scrollTop = 200
Debug.Print "DocEl: " & IE.Document.documentElement.scrollTop
IE.Document.body.scrollTop = 400
Debug.Print "body: " & IE.Document.body.scrollTop
Debug.Print "_______"
End If
Next
End Sub

Here's my result:

file:///C:/test1.html
body: 3352
DocEl: 0
DocEl: 0
body: 400
_______
file:///C:/Copy%20of%20test1.html
body: 0
DocEl: 0
DocEl: 0
body: 400
_______

documentElement is not even working for me
in IE8. Body is not available in a FRAMESET
page, of course, but in HTML4 it's required
otherwise. Even if you're using a frameset
page that doesn't explain how documentElement
is working. I don't think a frameset can scroll,
anyway.

------------------------------------
| I agree (IE 8.0.6001.18702):
|
| Dim SW As SHDocVw.ShellWindows, IE As InternetExplorer, WB As WebBrowser
| Set SW = New SHDocVw.ShellWindows
| For Each IE In SW
| Debug.Print IE.hwnd
| Debug.Print IE.document.body.scrollTop '# = 0
| Debug.Print IE.document.documentElement.scrollTop '# = correct
| IE.document.documentElement.scrollTop = 200 '# works
| Debug.Print IE.document.documentElement.scrollTop
| Next
|
| Juergen.
|
|


From: Mayayana on
I think I found the answer to this. It's bizarre,
but it fits the symptoms:

http://www.codehouse.com/javascript/articles/scroll_area/

The deal seems to be that if you use a DOCTYPE
tag in IE6+ that specifies standards compliance mode then
you have to use documentElement and body is broken.
But if you use "quirks mode" by not adding the DOCTYPE
tag, documentElement is broken and body works!

I find it hard to believe that MS actually went out
of their way to break the BODY properties, but it accords
with what I'm seeing. I had been testing my own pages,
which I always write without a DOCTYPE tag so that I
can get consistent behavior in a single webpage version
across all versions of IE.

I just tried the sample code with two pages open,
one compliant and one quirks mode. Get and Let both
worked fine without errors as long as both methods
were used. Each page worked with one of the methods
and ignored the other. It may be possible to test for
compliance vs quirks mode, but it doesn't seem to be
necessary.