Why the following code Based on Mozilla example does not work? Tried with Firefox 3.5.7 & Chrome.
I'm also assuming that you've opened your HTML test page directly in the browser judging by your reference to file:///.... For XMLHttpRequest calls, you need to serve the HTML from a server. Try something like xampp (http://www.apachefriends.org/en/xampp.html) to get a local server up and running and then run your test from http://localhost/XMLHTTP.html.
Note, this does not solve your same-origin problem, but this would allow the following code to work: