- PhantomJS Tutorial
- PhantomJS - Home
- PhantomJS - Overview
- PhantomJS - Environment Setup
- PhantomJS - Object
- PhantomJS - Methods
- WebPage Module
- PhantomJS - Properties
- PhantomJS - Methods
- PhantomJS - Events/Callbacks
- PhantomJS - Child Process Module
- File System Module
- PhantomJS - Properties
- PhantomJS - Methods
- System Module
- PhantomJS - Properties
- Web Server Module
- PhantomJS - Properties
- PhantomJS - Methods
- Miscellaneous
- Command Line Interface
- PhantomJS - Screen Capture
- PhantomJS - Page Automation
- PhantomJS - Network Monitoring
- PhantomJS - Testing
- PhantomJS - REPL
- PhantomJS - Examples
- PhantomJS Useful Resources
- PhantomJS - Quick Guide
- PhantomJS - Useful Resources
- PhantomJS - Discussion
PhantomJS - onConfirm()
This callback is called when there is a confirmed message called with ok /cancel from the page. Its return value to the callback is true or false, which is true for ok and false for cancel clicked on the confirm box.
Syntax
Its syntax is as follows −
wpage.onConfirm = function(msg) {};
Example
The following example shows the use of onConfirm() method.
var wpage = require('webpage').create(); wpage.onConfirm = function(msg) { console.log(msg); } wpage.open('http://localhost/tasks/confirn.html', function(status) { console.log(status); phantom.exit(); });
confirm.html
<html> <body> <script> window.confirmationValue = confirm("Press a button!"); </script> </body> </html>
The above program generates the following output.
Press a button! Success
phantomjs_webpage_module_events_callbacks.htm
Advertisements
To Continue Learning Please Login
Login with Google