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('http://localhost/tasks/prompt1.html', function(status) { });
上述程序生成以下输出。
{"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_webpage_module_events_callbacks.html