Title: Page 111 – Alex Kirk

---

 * 
   ## 󠀁[Firefox 1.5, XmlHttpRequest, req.responseXML and document.domain](https://alex.kirk.at/2006/07/27/firefox-15-xmlhttprequest-reqresponsexml-and-documentdomain/)󠁿
   
 * July 27, 2006
 * Recently I have been working on a web application, extending it with an iframe
   on another subdomain.
 * When you set up communication with an iframe on another subdomain, it works by
   setting document.domain in both pages. Pretty nice and straight forward.
    But
   it can mess up the rest of your page.
 * As soon as you have set document.domain you should be able to do an XHR to your
   original domain according to the same domain policy.
 * 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](https://bugzilla.mozilla.org/show_bug.cgi?id=290100).
   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");)
 * I have some [sample code available here](https://alex.kirk.at/cross_subdomain_iframe/?output_format=md&term_id=1122).
 * Apparently a [bug report has been filed at 1.5.0.1](https://bugzilla.mozilla.org/show_bug.cgi?id=326337).
   No response from developers. Great.
    Unfortunately it has only been filed for
   OSX, but it also afffects Windows Firefox.
 * Mozilla guys, fix this ASAP.
 * **Update 2007-06-21:** Things seem to start moving, we will likely [have a fix](https://bugzilla.mozilla.org/show_bug.cgi?id=326337)
   for Firefox 3.
 * firefox bug, document.domain, XmlHttpRequest, responseXML
 * [Ajax](https://alex.kirk.at/category/code/ajax/)
 * 
   ## 󠀁[Misuse of the Array Object in JavaScript](https://alex.kirk.at/2006/05/18/misuse-of-the-array-object-in-javascript/)󠁿
   
 * May 18, 2006
 * There is a very good post about [Associative Arrays considered harmful](http://www.andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/)
   by [Andrew Dupont](http://www.andrewdupont.net/about/).
 * The title is a bit misleading but correct. When coming accross a piece of JavaScript
   like this
    `foo["test"] = 1;` there is nothing wrong about it. It’s the basic
   usage scheme of assoziative arrays. Or should i rather say objects?
 * While in languages such as PHP arrays used like this `$foo = array("test" => 
   1);` is perfectly correct.
 * In JavaScript
    `var foo = new Array(); foo["test"] = 1; works but does not do
   what you want.
 * I don’t need to repeat Andrew’s really great post, but basically you should use`
   Object` instead of `Array`.
 * `var foo = new Object(); // same as var foo = {};
    foo["test"] = 1; // same as
   foo.test = 1;
 * Now go and read [Andrew’s post](http://www.andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/).
 * via [Erik Arvidsson](http://erik.eae.net/archives/2006/05/18/10.31.01/).
 * btw: that post lead me to [Object.prototype is verboten](http://erik.eae.net/archives/2005/06/06/22.13.54/)
   which explains for me why my `for (i in myvar) {}` loops never worked correctly.
   I was using [prototype.js](http://prototype.conio.net/) version < 1.4 (which 
   messed with Object.prototype).
 * javascript, array, object, prototype.js, Object.prototype
 * [Ajax](https://alex.kirk.at/category/code/ajax/), [Code](https://alex.kirk.at/category/code/)

 [Previous Page](https://alex.kirk.at/page/110/?output_format=md&term_id=1122) [Next Page](https://alex.kirk.at/page/112/?output_format=md&term_id=1122)