StringingLong Posted September 20, 2012 Share Posted September 20, 2012 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? Link to comment Share on other sites More sharing options...
DaleHohm Posted September 20, 2012 Share Posted September 20, 2012 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 Link to comment Share on other sites More sharing options...
StringingLong Posted September 21, 2012 Author Share Posted September 21, 2012 (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 September 21, 2012 by StringingLong Link to comment Share on other sites More sharing options...
DaleHohm Posted September 21, 2012 Share Posted September 21, 2012 (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 September 21, 2012 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 Link to comment Share on other sites More sharing options...
StringingLong Posted September 23, 2012 Author Share Posted September 23, 2012 (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 September 24, 2012 by StringingLong Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now