Phantomjs-onurlchanged

提供:Dev Guides
2020年6月23日 (火) 08:10時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

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