Sign in to follow this  
Followers 0
timmalos

IE Get an attribute

6 posts in this topic

Hello everybody. I'm a french and i tried to use the Search function of the forum without result, so i hope you will help me.

There is my problem :

I try to make a function which will reproduce the actions that the user can do in Internet Explorer.

So i attach ie, etc... everything is ok.

But when the user click on a link fired with 'onclick', i want to know when. To make this, with each page i check all the links and i want to know if one of them contain javascript, and the function called.

Global $i_links[1][1],$i_forms[1][1]

    ;//////////////////////////////////////////
    ;Get Link Infos
    ;//////////////////////////////////////////
    Local $oLinks = _IELinkGetCollection ($oIE)
    iF @error = 0 Then
        If @extended <> 0 then  ReDim $i_links[@extended][3]
        $i = 0

        For $oLink In $oLinks
            $i_links[$i][0] = $oLink.outertext
            $i_links[$i][1] = $oLink.href
            $i_links[$i][2] = $oLink.alt
            $i += 1
        Next
    EndIf

    ;//////////////////////////////////////////
    ;Get Forms Infos
    ;//////////////////////////////////////////
    Local $oForms = _IEFormGetCollection($oIE)
    If @error = 0 Then
        If @extended <> 0 then  ReDim $i_forms[@extended][5]
        $i = 0
        For $oForm In $oForms
            $i_forms[$i][0] = $oForm.name
            $i_forms[$i][1] = $oForm.action
            $i_forms[$i][2] = $oForm.method
            $i_forms[$i][3] = $oForm.innertext
            $i_forms[$i][4] = $oForm.getAttribute("onsubmit")
            $i += 1
        Next
    EndIf

As you see, i'm searching all infos as possible of $oForm. But how can i get a list of the attributes possible? Because name, action, method,innertext was just some tests with luck, but now i want to know the "$('#dialog').dialog('open');" of <form name="form1" enctype="multipart/form-data" method="post" onsubmit="$('#dialog').dialog('open');"/> but the getAttribute doesn't work, and $oForm.onsubmit either, same thing for $oForm.FireEvent("onsubmit") whitch make the javascript called but don't give me the onsubmit value.

I hope you have understood, however i will repeat : First thing I need to know the onsubmit value (here $('#dialog').dialog('open');) and Second i want to know if there is a link somewhere to give me all possible attributes for $oForm, like action, method, etc... and a link for the same thing for $oLink, $oImg because i don't find in MSDN.

Sorry for these little questions, and thx you for help.

Tim

Share this post


Link to post
Share on other sites



You can read the value of Javascript variables directly. This demo was posted by DaleHohm:

#include <IE.au3>

$oIE = _IECreate()
_IEDocWriteHTML($oIE, "<html><head><script luanguage = 'javascript'>foo='bar';</script></head><body></body></html>")

ConsoleWrite("foo = " & $oIE.document.parentwindow.eval('foo') & @CR)

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thx you for reply, but here you get 'bar' because it's a chain of characters, but when the script is a function, i don't want to execute the function , i want to know if there is javascript.

In fact, one the first hand i want to list all the links that haven't javascript, which don't have any onclick events and one the second hand i want to list the links that have javascript, to change my method of click (Those with javascript with _IEAction("click") the others with _IELinkClik...

Share this post


Link to post
Share on other sites

Try this:

#include <IE.au3>

$oIE = _IEAttach("IE Get an attribute")

$oLinks = _IELinkGetCollection($oIE)

For $oLink in $oLinks
    ConsoleWrite($oLink.getAttributeNode('onclick').NodeValue & @CRLF)
Next

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

#5 ·  Posted (edited)

Thx you a lot Dale

Can i ask you how you know this? There is any doc about this? I don't find it in msdn...

Edit : After test, it seems dosn't work with form element object.

Local $oForms = _IEFormGetCollection($oIE)
    If @error = 0 Then
        If @extended <> 0 then  ReDim $i_forms[@extended][5]
        $i = 0
        For $oForm In $oForms
            $i_forms[$i][0] = $oForm.name
            $i_forms[$i][1] = $oForm.action
            $i_forms[$i][2] = $oForm.method
            $i_forms[$i][3] = $oForm.innertext
            $i_forms[$i][4] = $oForm.getAttributeNode('onclick').NodeValue
            $i += 1
        Next
    EndIf
Edited by timmalos

Share this post


Link to post
Share on other sites

IE has notorious problems with getAttribute. Google IE Attribute hell

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

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