PhantomJS - onResourceError()



當網頁無法上傳檔案時呼叫此回撥。其引數是錯誤物件。

錯誤物件包含以下內容:

  • Id - 請求的編號。

  • URL - 呼叫的 URL。

  • ErrorCode - 錯誤程式碼。

  • ErrorString - 錯誤詳情

語法

語法如下:

wpage.onResourceError = function(resourceError) {}

示例

以下示例演示了 onResourceError() 方法的使用。

var wpage = require('webpage').create(); 
wpage.onResourceError = function(error) { 
   console.log(JSON.stringify(error));   
} 
wpage.open('https:///tasks/prompt1.html', function(status) {  
});

上述程式生成以下 輸出

{"errorCode":203,"errorString":"Error downloading https:///tasks/prompt
.html - server replied: Not Found","id":1,"status":404,"statusText":"Not Found",
"url":"https:///tasks/prompt1.html"}
phantomjs_webpage_module_events_callbacks.htm
廣告
© . All rights reserved.