Home > Language Reference > Web Functions > CopyLink

CopyLink

The CopyLink function retrieves the address of the hyperlink's target for the specified HTML element.

Usage

ClickHTMLElement function clicks the hyperlink, CopyLink function returns the corresponding url.

Syntax

ret=CopyLink(<html_descriptor>, var$)

Parameters

<html_descriptor>, string, HTML descriptor of the HTML element from which to extract the hyperlink. Use Spy tool to generate the <html_descriptor> parameter.

var$, string, url of the hyperlink.

Return value

Ret, optional numeric return code. If the specified HTML element has been found within 30 seconds (this default value can be changed using #ActionTimeout), the function returns 0. If the function fails, the return value is a nonzero value (see Web Functions Error Codes).

Remarks

CopyLink function returns the actual link which is behind a clickable link. It simulates a right click on the specified html element, and in the context menu takes the option Copy shortcut.

See also

ClickHTMLElement

Examples

'On WinTask Demo website, retrieve the link behind Form link
StartBrowser("IE","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
CopyLink("A[INNERTEXT= 'Form']",link$)
msgbox(link$)
'link$ contains http://www.wintask.com/demos/form.htm
CloseBrowser()

'On WinTask Demo website loaded in Firefox, retrieve the link behind Form link
StartBrowser("FF","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
CopyLink("A[INNERTEXT= 'Form']",link$)
msgbox(link$)
'link$ contains http://www.wintask.com/demos/form.htm
CloseBrowser()


'On WinTask Demo website loaded in Chrome, retrieve the link behind Form link
StartBrowser("CH","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
CopyLink("A[INNERTEXT= 'Form']",link$)
msgbox(link$)
'link$ contains http://www.wintask.com/demos/form.htm
CloseBrowser()