为什么我的代码不能用于chrome或FF

时间:2014-03-04 13:15:28

标签: javascript internet-explorer google-chrome firefox

这两个函数似乎只适用于IE。这是代码:

function onGridMembers(id,xml) {
    if (xml != "<Members/>" && ToHelpOrNotToHelp) {
        var domDoc = new ActiveXObject("Microsoft.XMLDOM");
        domDoc.loadXML(xml);
        var helpHtml2 = "";
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open("GET", "Dictionary.xml", true);
        xmlDictionary = xmlhttp.responseXML;
        xmlhttp.send();       
        helpHtml2 += xmlDictionary.selectSingleNode("Terms/Term[Key='" + domDoc.selectSingleNode("Members/Member/@UName").text + "']/Desc").text;
        alert(helpHtml2);           
    }
}



function onCommandClicked(nectoId, commandId, commnadCaption, xml)  {

    if (commandId == "ID223") {                // this one doesn't work in chrome
       window.open('file://server/Guide.docx'); 
    } else if (commandId == "ID225") {           // This one works in chrome
        window.open('http://server/Reports/Pages/Folder.aspx');                        
    } else if (commandId == "ID227") {       // this one doesn't work in chrome
        getComponentById("vvv","ww").setMenuItemState("ID227", "Hidden");
        getComponentById("vvv","ww").setMenuItemState("ID226", "Enable");

        ToHelpOrNotToHelp = false;        
    } else if (commandId == "ID226") {     // this one doesn't work in chrome
        getComponentById("vvv","ww").setMenuItemState("ID226", "Hidden");
        getComponentById("vvv","ww").setMenuItemState("ID227", "Enable");

        ToHelpOrNotToHelp = true;
    }
}

你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

我不确定第二个代码,但是第一个代码不能在IE之外的其他浏览器中工作,因为你使用的是ActiveX,这是MS-Only。

Firefox错误控制台通常会提供有关JS无法正常工作的有用信息。