Phantomjs-onurlchanged
提供:Dev Guides
PhantomJS-onUrlChanged()
これは、ナビゲーションを使用してURLが現在のURLから変更されたときに呼び出されます。 コールバックへの引数が1つあり、これは新しい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/requestl', function(status) {
var Content = '<html><body><div>Test div</div></body></html>';
var pageurl = 'http://localhost/tasks/cl';
wpage.setContent(Content, pageurl);
});
上記のプログラムは、次の output を生成します。
Entered onUrlChanged callback:
http://localhost/tasks/cl