Webpage Module Events/Callbacks


Advertisements

The callbacks available with the webpage module are described in the following table.

S.No Callbacks & Description
1 onAlert()

This callback is called when there is an alert on the page; the callback takes a string and does not return anything.

2 onCallback()

OnCallback is used to pass values from webpage to webpage object and it is done using the window.callPhantom() method, which internally invokes the onCallback function.

3 onClosing()

This is called when the window is closed either by using the page.close() method or the window.close() method.

4 onConfirm()

This callback is called when there is a confirmed message called with ok /cancel from the page.

5 onConsoleMessage()

This callback is used when there are console messages used in the webpage. The onConsoleMessage method takes 3 arguments.

6 onError()

It is called when there is JavaScript error. The arguments for onError are msg and stack trace, which is an array.

7 onFilePicker()

This is used for upload file the callback is called when user want to upload a file.

8 onInitialized()

This callback is invoked when the page is called before loading.

9 onLoadFinished()

This function is called when the page opened is fully loaded. It has one argument, which tells when loading was a success or a failure.

10 onLoadStarted()

This callback is invoked when the page starts loading.

11 onNavigationRequested()

This callback tells when the navigation event is taking place.

12 onPageCreated()

This callback is invoked when a new child window is opened by the page.

13 onPrompt()

This callback is called when a prompt is called by the web page. It takes 2 arguments, message and the answer. The return value is a string.

14 onResourceError()

This callback is called when the webpage is not able to upload the file.

15 onResourceReceived()

This callback is called when the resource requested by the page is received.

16 onResourceRequested()

This function is invoked when page requests a resource.

17 onResourceTimeout()

This callback is called when the requested resource times out, when settings.resourceTimeout is used.

18 onUrlChanged()

This is called when the URL changes from the current one using navigation. It has one argument to the call back, which is a new URL targetUrl string.

Advertisements