Thursday, July 27th, 2006
Pains of document.domain in FireFox 1.5
<p>Alexander Kirk has written about a problem with XHR, responseXML and document.domain in FireFox:This will work in IE, Safari, and Opera.
This will not work in Firefox 1.0. This is very awkward but at least it has been fixed in 1.5.
So it will work in Firefox 1.5. But:The responseXML object is useless. You can’t access it, you receive a Permission Denied when trying to access it’s content (e.g. documentElement). Very annoying.
Even stranger that responseText is still readable. What’s the reason for this? Is there some security risk i am unaware of or is it a plain bug?As the responseText is available there is a pretty simple fix: re-parse the XML, which is kinda stupid and cpu intense if you have a lot of them. (something like: var doc =
(new DOMParser()).parseFromString(req.responseText, “text/xml”);)
Related Content:











https://bugzilla.mozilla.org/show_bug.cgi?id=326337
See my post. Actually that bug had been opened on 2006-02-07 17:02 PDT and has not yet been dealt with.
I’m very familiar with this bug, and have been using the re-parse workaround for some time. You may be interested to know that Firefox exhibits a similar bug with stylesheets – once you set document.domain, you can no longer programatically access the contents of included css stylesheets – permission denied!
ps for gods sake fix this commenting system – its an embarassment
This site is becoming an embarrassment…talking about Ajax but the hole experience is so 90′s…where is the Ajax you’re talking about?
It’s just so full of links and text that I haven’t requested about in the first place…
Please fix the title so that it spells “Firefox” instead of “Firefox”.
Did you just realized you wasted extra energy when you reached your finger to the “Shift” key when you’re capitalizing the second F while you’re not supposed to ;) ?
And, by the way, the responseXML “bug” in Firefox isn’t a bug. As stated in MDC, Mozilla browsers will not make
responseXMLavailable unless the server serves the MIME typetext/xml.There are two ways to fix this. One is to alter the server’s script to make it serve the
Content-Type: text/xmlheader. The second way is to do something like this in your JavaScript code:if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
if (req.overrideMimeType) req.overrideMimeType("text/xml");
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
This will force Mozilla browsers to parse the responded XML in the XMLHttpRequest object, given that the XML is well-formed.
Shouldn’t all Ajaxians take note of this?
Donjis go mambi?
kourge’s method fails in firefox 2.0/1.5. I have set both the server response type and overridemimetype nothing works. I had to resort to reparsing the response text as xml. Needless it is a great pain in, you where! FF is the best browser but slowly it may be moving towards the Netscape way.