prog: (Default)
[personal profile] prog
Righto, I just sacrificed a couple of hours on the altar of trying to get shit to work in MSIE. On the plus side, I think I can eliminate one of the third-party libraries I've been using; MSIE was barking at it, and I find that I can do the same thing it was doing using Prototype, which the application already depends on.

On the minus side, MSIE's XML API eludes me. Consider this code snippet. Given xml_request, an XMLHttpRequest object:
    alert(xml_request.responseText); // This prints the correct thing.
    var xml_doc = xml_request.responseXML;
    var root_element = xml_doc.documentElement;
    if (root_element) {
        alert("I have a document element. I am a sane browser!");
    }
    else {
        alert("I have no document element. I must be MSIE. Fuck.");
    }


The initial alert() makes me sure that MSIE (as well as any other browser) is in fact reading the XML. I just can't do a damn thing with it after that; every attempt to peek into any DOMmish properties of xml_doc returns null.

xml_doc.firstChild and equivalent statements all fail equally (while succeeding on sane browsers). Wha?



Another good reason to drop the library I am dropping? It contains lines of code like this:

MWJ_ldD[MWJ_ldD.length-1].onreadystatechange = new Function( 'if( MWJ_ldD['+(MWJ_ldD.length-1)+'].readyState == 4 ) { '+oFunct+'(MWJ_ldD['+(MWJ_ldD.length-1)+'].load?MWJ_ldD['+(MWJ_ldD.length-1)+']:MWJ_ldD['+(MWJ_ldD.length-1)+'].responseXML); }' );

Holy hannah. That's no way to make friends.

Date: 2007-06-02 12:46 pm (UTC)
From: [identity profile] ahkond.livejournal.com
What do you get from alert(xml_request.responseXML)? Just to see whether it's empty or not ...

Is it possible that calling xml_request.responseText empties the xml_request object, and that subsequently calling .responseXML therefore returns an empty XML document?

Date: 2007-06-02 03:43 pm (UTC)
From: [identity profile] misuba.livejournal.com
No, responseXML should still be there. XHR objects aren't one-use like that. This does not mean that IE is doing anything sensible with the XML once it gets it, however. (I can't shake the feeling that it just has some minorly different way to get there than 'documentElement', but for the life of me I... ooh! I know! The flamingo book! I'll be right back)

August 2022

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 8th, 2025 06:20 pm
Powered by Dreamwidth Studios