javascript - Retrieve URI of an XML DOM object using Internet Explorer -
In the Firefox and Chrome documentURI
, the property of an XML Dome document node will return the property of DOM URI if it is created using the XMLHTTPRequest
object.
Is there an equal asset for Internet Explorer Dome, and if so what is it? The documentURI
, url
, url
and baseURI
attribute all return either blank or undefined.
url
For the property I hope this will return the URL used in the HTTP request that was created in DOM - but given examples does not use XMLHTTPRequest
.
The code used to make domes and then the following is the test of the property:
function getXslDom (url) {if (typeof XMLHttpRequest == "undefined" ) {XMLHttpRequest = function () {new ActiveXObject ("Msxml2.XMLHTTP.6.0"); }; } Var req = new XMLHttpRequest (); Req.open ("GET", url, false); Req.send (zero); Var position = req.status; If (condition == 200 || condition == 0) {return req.responseXML; } And "throw" "+ HTTP request for" + url + "with status code:" + status; }}; Var xslDom = getXslDom ('help.xsl'); IE shows the following "undefined" for the window. Alert (xslDom.documentURI);
I managed to work it by using the example from the linked MSX page I am:
& lt; Script & gt; Var getXslDom = function (url) {if (ActiveXObject === type of 'function') {var xmlDoc = new ActiveXObject ("Msxml2.DOMDocument.3.0"); XmlDoc.async = false; XmlDoc.load (URL); If (xmlDoc.parseError.errorCode! = 0) {var myErr = xmlDoc.parseError; Throw "You have an error" + myErr.reason; } And {back to xmlDoc; }} And {var req = new XMLHttpRequest (); Req.open ("GET", url, false); Req.send (zero); Var position = req.status; If (condition == 200 || condition == 0) {return req.responseXML; } And "throw" "+ HTTP request for" + url + "with status code:" + status; }}} Dom dom = getXslDom ('help.xsl') Warning (dom.documentURI || dom.url) & lt; / Script & gt;
This is it.
Cheers!
PS: I used "alert" only because OP used it, personally I prefer "console.log", which I would recommend OP I am
Comments
Post a Comment