javascript - how do i transform my code to work in chrome -
i have function works in ie not in chrome, because of "microsoft.xmldom" , selectsinglenode (i think), please me convert code chrome, thanks!
var xmldictionary = null;
function ongridmembersselection(id,xml) {
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); }
you can use xmlhttp=new xmlhttprequest();
instead of: var domdoc = new activexobject("microsoft.xmldom");
. other browsers ( firefox, chrome, opera, safari ).
and load xml file please use:
parser=new domparser(); xmldoc=parser.parsefromstring(txt,"text/xml");
as sated in below link..
http://www.w3schools.com/xml/xml_dom.asp
please try well..
var xmldictionary = null; function ongridmembersselection(id,xml) { // code ie if (window.activexobject || xhttp.responsetype=="msxml-document") { 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); } // code chrome, firefox, opera, etc. else if (document.implementation && document.implementation.createdocument) { var domdoc=new xmlhttprequest(); xmlhttp.open("get", "dictionary.xml", true); xmldictionary = xmlhttp.responsexml; xmlhttp.send(); xml.evaluate("terms/term[key='" +xml.evaluate("members/member/@uname", xmldictionary , null, xpathresult.any_type, null), xmldictionary , null, xpathresult.any_type, null).nodevalue; helphtml2 += .text; alert(helphtml2); } }
Comments
Post a Comment