Jump to content

Invoke Javascript Of A Loaded Html Page


Recommended Posts

Hi folks,

with my script I am running through HTML Forms, that are concatenated throught several posts and cookies and IDs and so on.

At one point I have to "push" a button in order to proceed. This button really isn´t a form button:

<td class="myButton" nowrap onclick="java script:commandRequest('abcde')">blabla</TD>

As you can see this would be hard to identify with IE.au3 functions /as far as I know) - there is no name or specific type.

I want to manage this whole thing in background, that´s why I can´t work with doClick and so on ... the IE window is hidden.

Does anyone know how to invoke an embedded Javascript? As I depend on the context (cookies, IDs ...) of the HTML Form I prefer an approach using the existing _IEDocumentGetObj or _IECreate object.

Thanks in advance!

Link to comment
Share on other sites

Hi folks,

with my script I am running through HTML Forms, that are concatenated throught several posts and cookies and IDs and so on.

At one point I have to "push" a button in order to proceed. This button really isn´t a form button:

<td class="myButton" nowrap onclick="java script:commandRequest('abcde')">blabla</TD>

As you can see this would be hard to identify with IE.au3 functions /as far as I know) - there is no name or specific type.

I want to manage this whole thing in background, that´s why I can´t work with doClick and so on ... the IE window is hidden.

Does anyone know how to invoke an embedded Javascript? As I depend on the context (cookies, IDs ...) of the HTML Form I prefer an approach using the existing _IEDocumentGetObj or _IECreate object.

Thanks in advance!

With IE.au3 you can do it with either eval or execscript. This example actually creates and writes a page with an embedded Javascript and then executes it with each of the methods...

$oIE = _IECreate()
$s = "<HTML><HEAD><script Language='Javascript'>function foo(){alert('Executed Externally...')}</SCRIPT></HEAD><BODY>This is a page</BODY></HTML>"
_IEDocWriteHTML($oIE, $s)
;
$oIE.document.parentwindow.execscript("foo()")
; Or
$result = $oIE.document.parentwindow.eval("foo()")

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...