问题描述
有没有什么办法来检查在JavaScript中,如果XMLHtt prequest对象支持 W3C进步活动?我的意思是,如果属性设置的onload,onprogress,onabort,onError的,等一些处理函数将有那些函数调用这些事件,如上所述。
Is there any way to check within JavaScript if XMLHttpRequest object supports W3C Progress Events? I mean here if setting onload, onprogress, onabort, onerror, etc. properties to some handler function would have those function called those events, as described.
附加(奖金)的问题:有没有办法来增强XMLHtt prequest(例如使用一些定时器),以支持这些事件
Additional (bonus) question: is there a way to augment XMLHttpRequest (e.g. using some timers) to support those events?
旁注:我第一次发现关于W3C进步活动中XMLHtt prequest here
推荐答案
您是否尝试过做这种方式?
Have you tried doing it this way?
try {
var xhr = new XMLHttpRequest();
if ('onprogress' in xhr) {
// Browser supports W3C Progress Events
} else {
// Browser does not support W3C Progress Events
}
} catch (e) {
// Browser is IE6 or 7
}
我测试了在Firefox和放大器; IE8。火狐表明它支持它。 IE浏览器说,它对于W3C进度事件的支持。
I tested this in Firefox & IE8. Firefox shows it supports it. IE says it has no support for W3C Progress events.
这篇关于如何检查在JavaScript中,如果XMLHtt prequest对象支持W3C的进度事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!