Jump to content

[R] Issue to manage OnClick in Javascript


Recommended Posts

Hello

After trying some Web's solutions, didn't figure out my problem ...

I'd like to click on a 'label' link called "Recherche avancée" that is managed by some Javascript

Here's HTML code
 

<tr>
    <input type="submit" name="action.standardsearch.search" value="Rechercher" class="im-button" id="imh_1" /></td>
</tr>
<tr>
    <td align="right"><label  style="text-decoration: underline;cursor:pointer;" onclick="imSubmitAction('action.standardsearch.detailed');">Recherche avancée</label></td>
</tr>
<tr>
    <td>La recherche ne peut renvoyer plus de 500 résultats.<BR>Si vous ne trouvez pas le compte recherché, veuillez affiner vos critères de recherche.</td>
</tr>

Tried this unsuccesfully

 

$oLabels = _IETagNameGetCollection ($oIE,"label")
For $oLabel In $oLabels
    If $oLabel.Onclick = "imSubmitAction('action.standardsearch.detailed');" Then 
        _IEAction($oLabel,"click")
        ExitLoop
    EndIf
Next

May you help me please to fix this issue ?

Regards

Edited by Ebola57
Link to comment
Share on other sites

A couple of suggestions --

1) Add a ConsoleWrite or a MsgBox inside the If statement so that you can be sure the desired element is being found

2) Instead of checking for onclick, it may work better to check for innertext --

$oLabels = _IETagNameGetCollection ($oIE, "label")
For $oLabel In $oLabels
    If _IEPropertyGet($oLabel, 'innertext') = "Recherche avancée" Then 
        ConsoleWrite('Found element!' & @CRLF)
        _IEAction($oLabel,"click")
        ExitLoop
    EndIf
Next

 

Link to comment
Share on other sites

35 minutes ago, Juvigy said:

Try :

$oIE.document.parentwindow.execScript("imSubmitAction('action.standardsearch.detailed');")

 

That's a flawless success ! Thanks a lot. At least now I learnt how to exce some part of J code

Link to comment
Share on other sites

1 hour ago, Danp2 said:

A couple of suggestions --

1) Add a ConsoleWrite or a MsgBox inside the If statement so that you can be sure the desired element is being found

2) Instead of checking for onclick, it may work better to check for innertext --

$oLabels = _IETagNameGetCollection ($oIE, "label")
For $oLabel In $oLabels
    If _IEPropertyGet($oLabel, 'innertext') = "Recherche avancée" Then 
        ConsoleWrite('Found element!' & @CRLF)
        _IEAction($oLabel,"click")
        ExitLoop
    EndIf
Next

 

That is very pertinent indeed, going to do some test in this way even if I have to catch Juvigy's solution at the moment

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...