Home > Language Reference > Web Functions > CurrentPage$

CurrentPage$

The CurrentPage$ function returns the current web page title.

Usage

Some Web sites have dynamic page titles (the title changes each time it loads), CurrentPage$ will retrieve the correct page title which can then be used as UsePage argument.

Syntax

var$=CurrentPage$()

Parameter

None.

Return value

var$, string, current web page title.

Remarks

CurrentPage$ returns the current web page title without any synchronization. So a StartBrowser or a UsePage must be in the script before, or an empty string will be returned.

Examples

StartBrowser("IE","www.wintask.com")
'Note that StartBrowser makes the automatic synchronization and waits until the page is loaded.
a$=currentpage$()
msgbox(a$)
CloseBrowser()

StartBrowser("FF","www.wintask.com")
'Note that StartBrowser makes the automatic synchronization and waits until the page is loaded.
a$=currentpage$()
msgbox(a$)
CloseBrowser()

StartBrowser("CH","www.wintask.com")
'Note that StartBrowser makes the automatic synchronization and waits until the page is loaded.
a$=currentpage$()
msgbox(a$)
CloseBrowser()


    
'Error sub-routine returning the non-expected page loaded after a link has been clicked and the page after that click is not the expected one:
sub iferror()
local page$
page$=currentpage$()
'page$ contains the page displayed just before the call to that function.
msgbox(page$)
usepage(page$)
'To come back to a known web page, we click Home in the error Sub
ClickHTMLElement("A[INNERTEXT= 'Home']")
endsub

 

'Call example on www.wintask.com
startbrowser("ie","www.wintask.com")

UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
'This clickhtmlelement loads a page and on this next page, a pause OCR is used to check if some text is there.
    ClickHTMLElement("A[INNERTEXT= 'DOWNLOAD your 30-day']")

UseOCREngine(1)
ret=0
Pause 30 until
    TextOCR("on the recording ")
    InWindow("IEXPLORE.EXE|Internet Explorer_Server||1",1)
PauseOK
 'If the Pause triggers, assign 1 to ret
    ret=1
PauseFalse
 'If the Pause does not trigger within 30 secs, assign 0 to ret
    ret=0
EndPause

if ret=0 then
    'The pause OCR failed if ret=0, so we call the Error Sub to know which page title is currently displayed
    iferror()
endif