Jump to content

IE and onclick\javascript:void(0) link

Recommended Posts

I am wondering if there is a quicker and more robust way to achieve what the script below does. What I am trying to do is open a web page, click a link then do some stuff with the linked page.

This is a minimal producer from a bigger script, no error checking etc, that opens the web page, searches the page for a link (it's an onclick link and despite my best try couldn't get it to click) based on a string, then combines two strings to get the link and navigates to it.

The issue is the main part of the final url is hard coded in the script and could change in the future.

Any better solutions?


#include <IE.au3>

_Web_GetUpdateInfoFromMUC('Update for Microsoft Office 2010 (KB3114555) 64-Bit Edition')

Func _Web_GetUpdateInfoFromMUC($s_Title)
    Local $o_IE = _IECreate('https://catalog.update.microsoft.com/v7/site/Search.aspx?q=' & $s_Title)

    $v_Ret = _Web_MucGetUpdateDetailsUrl($o_IE, $s_Title)

    If $v_Ret Then _IENavigate($o_IE, $v_Ret)
    MsgBox(0, 'Wait', 'This is the url I want')

EndFunc   ;==>_Web_GetUpdateInfoFromMUC

Func _Web_MucGetUpdateDetailsUrl(ByRef $o_Browser, $s_Title)
    Local $s_Url = ''
    Local $o_Links = _IELinkGetCollection($o_Browser)

    If Not @error Then
        For $o_Link In $o_Links
            If StringInStr(_IEPropertyGet($o_Link, "innerText"), $s_Title) Then
                $s_Url = StringReplace($o_Link.id, '_link', '')

    ; below is the hard coded part that MS may change
    Return 'https://catalog.update.microsoft.com/v7/site/ScopedViewInline.aspx?updateid=' & $s_Url
EndFunc   ;==>_Web_MucGetUpdateDetailsUrl


Link to post
Share on other sites

I had tried this, but got a message about having a pop up blocker active (which I do) but this doesn't happen when I click the link manually so thought I was doing something wrong. The normal action is to open a pop up window, but I got around that with IENavigate.

I had also tried IELinkClickByText and Index


Edited by benners
Link to post
Share on other sites

Yes, I had to specifically tell IE that it was ok to allow popups for this site. Then the _IEAction worked as expected. I only pointed out the ability to click the link because you stated earlier that you were unable to accomplish this.

Have you considered using _INetGetSource and then parse the resulting text to retrieve the desired data? Perhaps one of the Regex gurus around here could assist with this.

Link to post
Share on other sites

I hadn't any success when I posted but even though I should have just walked away after posting I had to persist :mad2:

I hadn't thought about _INetGetSource, I will look into it and see if I can make it quicker.


Edited by benners
Link to post
Share on other sites
  • 2 years later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...