onNavigationRequested
Introduced: PhantomJS 1.6
By implementing this callback, you will be notified when a navigation event happens and know if it will be blocked (by page.navigationLocked).
Arguments
url: The target URL of this navigation eventtype: Possible values include:'Undefined','LinkClicked','FormSubmitted','BackOrForward','Reload','FormResubmitted','Other'willNavigate:trueif navigation will happen,falseif it is locked (bypage.navigationLocked)main:trueif this event comes from the main frame,falseif it comes from an iframe of some other sub-frame.
Examples
var webPage = require('webpage');
var page = webPage.create();
page.onNavigationRequested = function(url, type, willNavigate, main) {
console.log('Trying to navigate to: ' + url);
console.log('Caused by: ' + type);
console.log('Will actually navigate: ' + willNavigate);
console.log('Sent from the page\'s main frame: ' + main);
}