Sign in to follow this  
Followers 0
StringingLong

IE Document Scrolling Problem

5 posts in this topic

Having problems attempting to scroll the browser page in IE in some websites.

#include <IE.au3>

$oIe = _IECreate()
;$url1 = "https://signup.live.com/signup.aspx"   DOESNT SCROLL
;$url2 = "http://www.twitter.com"                        DOESNT SCROLL
;$url3  = "http://www.yahoo.com"                       SCROLLS
;$url4 = "http://www.facebook.com"                 SCROLLS
_IENavigate($oIe, $url)
$oIe.document.parentwindow.scroll(0, 200)

Any solutions to this?

Share this post


Link to post
Share on other sites



I expect there is Javascript code on those pages that is actively working against you by scolling certain items into view in the background. I doubt that the .scoll method is not working.

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

#3 ·  Posted (edited)

Hi Dale thanks for reply.

Yes, I figured Javascript is getting in the way here. I wanted to run this by anyone here to ask if there is a workaround for this.

Looking at the JS source for the first url above, I see the exact line of JS causing this. It is housed in a function and gets called throughout many places.

The function situates around setting focus and calls scrollIntoView(true). I believe that is where it is forcing the issue.

I understand there is _IEHeadInsertEventScript to insert the overriding JS (btw, thanks for writing IE UDF). Looking at IE UDF source, this is appended (inserted after) into the head tag.

The args are:

$o_object = $oIe

$s_htmlFor = "document"

$s_event = ??? there is no event

$s_script = the overriding script

The third arg, $s_event though, seems to not let me be able to use this. The reason is because I am not trying to override a event, but rather a JS function.

It looks like I have to write my own _IEInsertJS to get around this?

Edited by StringingLong

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is a function I use in my own code to accomplish this, along with two others I wrote at the same time:

Func IEEval($o_object, $s_eval)
    Return $o_object.document.parentWindow.eval($s_eval)
EndFunc ;==>IEEval

Func IEHeadInsertScript($o_object, $s_script)
    Local $o_head, $o_element
    $o_head = _IETagNameGetCollection($o_object, "head", 0)
    $o_element = $o_object.document.createElement('script')
    $o_element.type = 'text/javascript'
    $o_element.text = $s_script
    $o_head.appendChild($o_element)
    Return 1
EndFunc ;==>IEHeadInsertScript
 
Func IEHeadInsertStyle($o_object, $s_style)
    Local $o_head, $o_element
    $o_head = _IETagNameGetCollection($o_object, "head", 0)
    $o_element = $o_object.document.createElement('style')
    $o_element.type = 'text/css'
    $o_element.styleSheet.cssText = $s_style
    $o_head.appendChild($o_element)
    Return 1
EndFunc ;==>IEHeadInsertStyle

Dale

Edited by DaleHohm

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

#5 ·  Posted (edited)

Dale, thanks for this. These three will come in very handy later.

I tried using IEHeadInsertScript() and overloading the function which I thought was causing the page to not scroll. I basicaly set it to do nothing and not pass the call onto the original JS function.

Unfortunately,it didnt trigger any execution at all.

I eventually came to a solution involving using _IEAction($formObj, "focus") along with Send tab keys and reverse tab keys to scroll. Not the most ideal solution as it involves knowing what form fields fit the height of the screen/page and of course it is screen height dependent. But for now it works.

Edited by StringingLong

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