In PhantomJS, it's possible to get the URL of the page that is closing, e.g.:
var webPage = require('webpage');
var page = webPage.create();
page.onClosing = function(closingPage) {
console.log('The page is closing! URL: ' + closingPage.url);
};
But in node-phantom-simple, a "page.onClosing" handler doesn't have any usable arguments.
Suggested fix:
Due to the asynchronous nature of the bridge calling "set_page" on the page isn't practical because the page will be closed before the wrapped page can be used.
However, generally I just need the url and perhaps the title of the closing page, so suggest that just the url get passed back in the "onClosing" method. Change would be in line 165 of bridge.js, change:
if (cb === 'onClosing') { args = [ ]; }
to
if (cb === 'onClosing') { args = [ {url: parm.url, title: parm.title } ]; }
In PhantomJS, it's possible to get the URL of the page that is closing, e.g.:
But in node-phantom-simple, a "page.onClosing" handler doesn't have any usable arguments.
Suggested fix:
Due to the asynchronous nature of the bridge calling "set_page" on the page isn't practical because the page will be closed before the wrapped page can be used.
However, generally I just need the url and perhaps the title of the closing page, so suggest that just the url get passed back in the "onClosing" method. Change would be in line 165 of bridge.js, change:
if (cb === 'onClosing') { args = [ ]; }to
if (cb === 'onClosing') { args = [ {url: parm.url, title: parm.title } ]; }