2014-03-04 84 views
0

這兩個函數似乎只能在IE上運行。這是代碼:爲什麼我的代碼無法在Chrome或FF中工作

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

使用僅限IE的ActiveX對象(如'Microsoft.'進一步暗示的),奇怪它爲什麼不能在IE之外工作... –

+0

https://developer.mozilla.org/zh-CN/docs/ Parsing_and_serializing_XML – CBroe

回答

0

我不確定第二個代碼,但第一個代碼不能在IE瀏覽器中工作,因爲您使用的是僅限MS的ActiveX。

Firefox錯誤控制檯通常會提供有關JS爲什麼不起作用的有用信息。

相關問題