Take the 2-minute tour ×

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.

Additional (bonus) question: is there a way to augment XMLHttpRequest (e.g. using some timers) to support those events?

Sidenote: I have first found about W3C Progress Events in the context of XMLHttpRequest here

share|improve this question

1 Answer 1

up vote 9 down vote accepted

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

I tested this in Firefox & IE8. Firefox shows it supports it. IE says it has no support for W3C Progress events.

share|improve this answer
Alternative to if (xhr.onload !== undefined) { ... } is to use if ('onload' in xhr) { ... } –  Jakub Narębski Aug 9 '09 at 12:35
it's better to test for 'onprogress' in xhr, because some browsers (Opera) implements onload/onerror, but not onprogress, although Opera doens't fires onprogress, but it can be emulated with: setInterval( { if (xhr.readyState === 3 && xhr.responseText !== last) xhr.onprogress(); }, 250); –  4esn0k Dec 1 '11 at 11:18
@4esn0k I've updated my answer. I wasn't aware that Opera had a different implementation. Thanks. –  Dan Herbert Dec 1 '11 at 14:24

Your Answer


