Sign in to follow this  
Followers 0
Noobster24

Scroll IE Window with window.scroll()

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I try to open a IE window (with _IECreate() ), after loading the website, the page must be scrolled down. In Javascript it's possible by using window.scroll().

So, this is what I tried:

#include <IE.au3>
$oIE = _IECreate("http://www.mediacollege.com/internet/javascript/page/scroll.html",0,1,1,0)
_IEHeadInsertEventScript ($oIE, "window", "onload", "window.scroll(0,150);")

Unfortunately this doesn't work for some reason, however this one works:

#include <IE.au3>
$oIE = _IECreate("http://www.mediacollege.com/internet/javascript/page/scroll.html",0,1,1,0)
_IEHeadInsertEventScript ($oIE, "window", "onbeforeunload", "window.scroll(0,150); alert('It scrolls');")

But that's 'onbeforeunload', I would like to use 'onload' (like in my first codesample).

Anyone got an idea how to solve this?

Thanks in advance,

Andreas

PS:

Yes I read this topic: http://www.autoitscript.com/forum/index.ph...=window++onload

but I can't get it working still.

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites



_IECreate, by default, does not give control back to your script until the onload event has already fired. So, just as in the other thread you reference it is silly to write an onload event to the page after it has already loaded.

That said, if your point is to scroll down on the page after it has loaded and your script gets control back right after it is loaded, why not just do this:

include <IE.au3>
$oIE = _IECreate("www.autoitscript.com")
$oIE.document.parentwindow.scroll(0,150)

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

_IECreate, by default, does not give control back to your script until the onload event has already fired. So, just as in the other thread you reference it is silly to write an onload event to the page after it has already loaded.

That said, if your point is to scroll down on the page after it has loaded and your script gets control back right after it is loaded, why not just do this:

include <IE.au3>
$oIE = _IECreate("www.autoitscript.com")
$oIE.document.parentwindow.scroll(0,150)

Dale

Wow, works like a charm. You posted exactly what I searched for. Thanks again. <_<

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0