Jump to content
Sign in to follow this  

IE element .addEventListener or ,attachEvent functionality

Recommended Posts


I am trying to track status change on a IE "select " element.

when i try something like:

While 1
        If $oIE<>0 Then ExitLoop
    $status = _IEGetObjById ($oIE, "status_change")
;~  MsgBox(0,"",$status.innertext)
    $asd = $status.attachEvent("onchange", "testing")

I get "The requested action with this object has failed." error . "testing" is the name of the function i have.

Tried replacing "testing" with testing() but still doesnt work. Even tried .addEventListener - js method but failed too.

Anyone knows how to make this work?

Share this post

Link to post
Share on other sites

Perhaps, something like this?

#include <IE.au3>

Local $oIE = _IECreate()
Local $sHTML = "<form>" & @CRLF & _
               "<p>Select a different option in the drop-down list box to trigger the onchange event." & @CRLF & _
               "<select name=""selTest"" onchange=""alert('Index: ' + this.selectedIndex + '\nValue: ' + this.options[this.selectedIndex].value)"">" & @CRLF & _
               "<option value=""Books"">Books</option>" & @CRLF & _
               "<option value=""Clothing"">Clothing</option>" & @CRLF & _
               "<option value=""Housewares"">Housewares</option>" & @CRLF & _
               "</select> </p>" & @CRLF & _

_IEBodyWriteHTML($oIE, $sHTML)

Local $oSelect = _IEGetObjByName($oIE, "selTest")
ObjEvent($oSelect, "_Select_")

While _IEPropertyGet($oIE, "hwnd") <> 0

Func _Select_onchange()
    ConsoleWrite($oSelect.options($oSelect.selectedIndex).value & @CRLF)

The HTML source is from the onchange event example code from the MSDN web site.

Share this post

Link to post
Share on other sites

10x . I see where my error is now!

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.