From: Mike S on
On 7/3/2010 1:10 PM, Juergen Thuemmler wrote:
> Hi Mayayana,
>
>> Yes, you can set it. I use that method to store
>> and restore the scroll position of a WB. The following
>> simple VBScript demonstrates it. Put a large HTML
>> file on the Desktop (edit path in script as necessary)
>> then run this script as a .VBS file.
> </>
> thank you very much for your detailed response. I'll try it, but it may take
> some days...
> Juergen.

I think the version of IE and the doctype might make a difference but I
haven't used it since before IE8 was release so I'm not sure, this
worked on several sites:

Public IE As Object

Private Sub Command1_Click()
'create new IE window
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate2
"http://www.google.com/search?&q=visual+basic+automate+IE8"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Sleep 100
DoEvents
Loop
End Sub

Private Sub Command2_Click()
'end program
Set IE = Nothing
Unload Me
End Sub

Private Sub Command3_Click()
IE.document.documentElement.scrollTop = Text1.Text
DoEvents
Command4.Value = True
End Sub

Private Sub Command4_Click()
Label1.Caption = IE.document.documentElement.scrollTop
DoEvents
End Sub

Mike
From: Mayayana on

|
| I think the version of IE and the doctype might make a difference but I
| haven't used it since before IE8 was release so I'm not sure, this
| worked on several sites:
|

That works for you in IE8? It doesn't work for
me in IE6. According to the docs, document.documentElement
returns the HTML element. That does have a scrollTop
property, but for me it returns 0 always and setting
it doesn't work. And I don't see why it should. HTML is
not a visible element.
What's wrong with using Body.scrollTop? I think that works
since IE4.

The MS page for this...
http://msdn.microsoft.com/en-us/library/ms533739(v=VS.85).aspx
....says that documentElement is defined by the W3C
DOM. And my object browser (with IE6) lists a full
range of properties for HTMLhtmlElement. But it seems
that not all of them work. Maybe MS just added them
all to conform to the W3C, without bothering to back
them up. The HTML element only had a handful of
properties as of IE4, and no events. By IE6 it seems
they've suddenly added all properties and events to
all elements! There's even a click event and a cloneNode
method for <HTML>. That doesn't make any sense at
all.

In any case, if you're distributing code beyond your own
PC it should work at least back to IE6. Last I heard (fairly
recently) IE6 is still the most-used version of IE and is
likely to stay so for some time because a lot of corporate
intranet code depends on it. (And a lot of people still
use XP, which came with IE6.)

| Public IE As Object
|
| Private Sub Command1_Click()
| 'create new IE window
| Set IE = CreateObject("InternetExplorer.Application")
| IE.Visible = True
| IE.Navigate2
| "http://www.google.com/search?&q=visual+basic+automate+IE8"
| Do While IE.ReadyState <> READYSTATE_COMPLETE
| Sleep 100
| DoEvents
| Loop
| End Sub
|
| Private Sub Command2_Click()
| 'end program
| Set IE = Nothing
| Unload Me
| End Sub
|
| Private Sub Command3_Click()
| IE.document.documentElement.scrollTop = Text1.Text
| DoEvents
| Command4.Value = True
| End Sub
|
| Private Sub Command4_Click()
| Label1.Caption = IE.document.documentElement.scrollTop
| DoEvents
| End Sub
|
| Mike


From: Mike S on
On 7/3/2010 6:26 PM, Mayayana wrote:
> |
> | I think the version of IE and the doctype might make a difference but I
> | haven't used it since before IE8 was release so I'm not sure, this
> | worked on several sites:
> |
>
> That works for you in IE8? It doesn't work for
> me in IE6. According to the docs, document.documentElement
> returns the HTML element. That does have a scrollTop
> property, but for me it returns 0 always and setting
> it doesn't work. And I don't see why it should. HTML is
> not a visible element.
> What's wrong with using Body.scrollTop? I think that works
> since IE4.

I believe IE6 works with IE.document.body.scrollTop and
IE.Document.documentElement.scrollTop works for IE8 then maybe he could
load a browser, detect what version it is, then use the appropriate code?

> The MS page for this...
> http://msdn.microsoft.com/en-us/library/ms533739(v=VS.85).aspx
> ...says that documentElement is defined by the W3C
> DOM. And my object browser (with IE6) lists a full
> range of properties for HTMLhtmlElement. But it seems
> that not all of them work. Maybe MS just added them
> all to conform to the W3C, without bothering to back
> them up. The HTML element only had a handful of
> properties as of IE4, and no events. By IE6 it seems
> they've suddenly added all properties and events to
> all elements! There's even a click event and a cloneNode
> method for<HTML>. That doesn't make any sense at
> all.


> In any case, if you're distributing code beyond your own
> PC it should work at least back to IE6. Last I heard (fairly
> recently) IE6 is still the most-used version of IE and is
> likely to stay so for some time because a lot of corporate
> intranet code depends on it. (And a lot of people still
> use XP, which came with IE6.)

If IE.document.body.scrollTop works for IE6 and
>
> | Public IE As Object
> |
> | Private Sub Command1_Click()
> | 'create new IE window
> | Set IE = CreateObject("InternetExplorer.Application")
> | IE.Visible = True
> | IE.Navigate2
> | "http://www.google.com/search?&q=visual+basic+automate+IE8"
> | Do While IE.ReadyState<> READYSTATE_COMPLETE
> | Sleep 100
> | DoEvents
> | Loop
> | End Sub
> |
> | Private Sub Command2_Click()
> | 'end program
> | Set IE = Nothing
> | Unload Me
> | End Sub
> |
> | Private Sub Command3_Click()
> | IE.document.documentElement.scrollTop = Text1.Text
> | DoEvents
> | Command4.Value = True
> | End Sub
> |
> | Private Sub Command4_Click()
> | Label1.Caption = IE.document.documentElement.scrollTop
> | DoEvents
> | End Sub
> |
> | Mike
>
>

From: Mayayana on

| I believe IE6 works with IE.document.body.scrollTop and
| IE.Document.documentElement.scrollTop works for IE8 then maybe he could
| load a browser, detect what version it is, then use the appropriate code?
|

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.


From: Mike S on
On 7/3/2010 7:50 PM, Mayayana wrote:
> | I believe IE6 works with IE.document.body.scrollTop and
> | IE.Document.documentElement.scrollTop works for IE8 then maybe he could
> | load a browser, detect what version it is, then use the appropriate code?
> |
>
> 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.

Mike