Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get url of page being closed in onClosing handler. #132

Open
samir-mahendra opened this issue Apr 29, 2016 · 0 comments
Open

Unable to get url of page being closed in onClosing handler. #132

samir-mahendra opened this issue Apr 29, 2016 · 0 comments

Comments

@samir-mahendra
Copy link

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 } ]; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant