[Solved] Uncaught ReferenceError: ActiveXObject is not defined Error in Chrome

i have this error in Chrome
“Uncaught ReferenceError: ActiveXObject is not defined “

my code is

function loadModel() {

            //----------------------------------------------------------------------------------------------
            document.getElementById("lModelMsg").innerText = "Loading...";
            document.getElementById("lPartMsg").innerText = "";
            var dMfg = document.getElementById("dManufacturer");
            var id = dMfg.options[dMfg.selectedIndex].value;
            var xml = CreateAsset.LoadModel(id);
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            var Flag;
            Flag = xmlDoc.loadXML(xml.value);
            if (Flag) {......................

Solution #1:

ActiveX is a Microsoft-proprietary framework. It is supported only in MS products (i.e, IE)

You can use jQuery’s parseXML method as a cross-browser alternative.

Respondent: MasterAM

Solution #2:

As stated by others, ActiveX is an IE-specific technology.

Try this:

if (window.DOMParser)
{ // Firefox, Chrome, Opera, etc.
    parser=new DOMParser();
    xmlDoc=parser.parseFromString(xml,"text/xml");
}
else // Internet Explorer
{
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlDoc.loadXML(xml); 
} 
Respondent: Karl Anderson

Solution #3:

The problem is the security setting of your browser is blocking it.

If you try IE6 the code should work. You have to use a dead browser because the new browsers block it from working as part of a killbit fix that Microsoft did to fix a security issue.

Respondent: Prabakaran G

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.