- 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 - onUrlChanged()
This is called when the URL changes from the current one using navigation. It has one argument to the callback, which is the new URL targetUrl string.
Syntax
Its syntax is as follows −
page.onUrlChanged = function(targetUrl) {}
Example
var wpage = require('webpage').create(); wpage.onUrlChanged = function(targeturl) { console.log("Entered onUrlChanged callback:"); console.log(targeturl); } wpage.settings.resourceTimeout = '3'; wpage.open('http://localhost/tasks/request.html', function(status) { var Content = '<html><body><div>Test div</div></body></html>'; var pageurl = 'http://localhost/tasks/c.html'; wpage.setContent(Content, pageurl); });
The above program will generate the following output.
Entered onUrlChanged callback: http://localhost/tasks/c.html
phantomjs_webpage_module_events_callbacks.htm
Advertisements