當網頁無法上傳文件時調用此回調。它的參數是錯誤對象。
錯誤對象包含 -
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('http://localhost/tasks/prompt1.html', function(status) {
});
上述程序生成以下內容output。
{"errorCode":203,"errorString":"Error downloading http://localhost/tasks/prompt .html - server replied:Not Found","id":1,"status":404,"statusText":"Not Found", "url":"http://localhost/tasks/prompt1.html"}
相關用法
- PhantomJS onResourceRequested()用法及代碼示例
- PhantomJS onResourceReceived()用法及代碼示例
- PhantomJS onResourceTimeout()用法及代碼示例
- PhantomJS onConsoleMessage()用法及代碼示例
- PhantomJS onPageCreated()用法及代碼示例
- PhantomJS onUrlChanged()用法及代碼示例
- PhantomJS onNavigationRequested()用法及代碼示例
- PhantomJS onAlert()用法及代碼示例
- PhantomJS onFilePicker()用法及代碼示例
- PhantomJS onCallback()用法及代碼示例
- PhantomJS onConfirm()用法及代碼示例
- PhantomJS onError()用法及代碼示例
- PhantomJS onPrompt()用法及代碼示例
- PhantomJS open()用法及代碼示例
- PhantomJS setContent()用法及代碼示例
注:本文由純淨天空篩選整理自 PhantomJS - onResourceError()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。