Skip to content

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

Description

@samir-mahendra

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions