Skip to content Skip to sidebar Skip to footer

Will These Activexobject And Xmlhttprequest Checks Apply For Any Other Browser Than Ie6?

I got a weird error in IE10 for plUpload plugin, and I found that if I remove this code in our project everything works fine. Can anyone tell me exactly what this does and if it's

Solution 1:

Yes, I believe there are other browsers. The checks you show are trying to detect IE by looking for browsers with ActiveX support (IE*), but no XMLHttpRequest support (IE6-). However if the ie7xmlhttp flag is presumably initialized to null or undefined, then any non-IE browser that doesn't have XMLHttpRequest support will be treated similarly since if(typeof XMLHttpRequest == "undefined" || !ie7xmlhttp) { will be true in those cases.

Thus, pretty much any older browser w/out XMLHttpRequest support will fall into the if block that tries to shim the XMLHttpRequest API. Not that there are a lot of people using them, but I'm sure they're out there. (e.g. particularly old versions of FF, Opera, Safari... lesser known mobile browsers maybe... that sort of thing.)

BTW, Microsoft's XMLHttpRequest documentation recommends this code snippet for x-platform XMLHttpRequest construction, which I recommend:

functiongetXMLHttpRequest() 
{
    if (window.XMLHttpRequest) {
        returnnewwindow.XMLHttpRequest;
    }
    else {
        try {
            returnnewActiveXObject("MSXML2.XMLHTTP.3.0");
        }
        catch(ex) {
            returnnull;
        }
    }
}

Post a Comment for "Will These Activexobject And Xmlhttprequest Checks Apply For Any Other Browser Than Ie6?"