Jump to content
Sign in to follow this  
Juvigy

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
        $oIE=_IEAttach($atachadres,"url")
        If $oIE<>0 Then ExitLoop
        Sleep(10000)
    WEnd
    $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 & _
               "</form>"

_IEBodyWriteHTML($oIE, $sHTML)

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

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

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

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...