PhantomJS - onUrlChanged()
当使用导航更改当前 URL 时,将调用此方法。它有一个回调参数,即新的 URL targetUrl 字符串。
语法
其语法如下 −
page.onUrlChanged = function(targetUrl) {}
示例
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);
});
上述程序将生成以下输出。
Entered onUrlChanged callback: http://localhost/tasks/c.html
phantomjs_webpage_module_events_callbacks.html

