IframeXHR

Once again I've been working my tail off on HTML AJAX and it's time for a new release. I'm not doing this out of any altruism - I just want a nicely debugged working ajax solution that I can hack into kalfu properly. The biggest project this time around has been IframeXHR (xmlhttprequest) - a javascript class designed to be transparent to any wrapper class using the xmlhttprequest api. The trick with this is browser limitations on iframes. Opera's security is so over the top that if I set the src to about:blank or nothing and try to location.replace to a regular page and then read from that page I get security errors. So instead I have to set the src directly. So that means I have to "wrap" the data going to the server - not a big deal, it's done directly in the class, and then "unwrap" it at the server end - also not a big deal. The problem comes with data being sent back FROM the server.

Currently I'm embedding the returned data in an html page with an onload call - I haven't gotten anything else to work, because finding a cross browser method of finding the iframe document node and pulling the innerHTML has been an impossible prospect. But that means that a grab request won't work because the data coming in is not wrapped properly. In addition, IE has a strange limitation on the javascript while construction. I use a "while" hack to fake a sync request in most browsers. Only in IE all actions are blocked during that while loop - the onload from the iframe doesn't get called...in fact the iframe doesn't load at all - which means there's no way to do sync requests on IE. The grab limitation can be worked around by creating a "proxy" method in the HTML_AJAX php class which will set the right headers, run a request against a page, grab the data, and pump it into the html "wrapper" before returning it. It's just not something I've tackled yet. The sync problem is something I'm not sure I can get around.

In addition, gecko browsers apparently need a larger amount of time than any other browser to create the iframe, because you get an endless loop. Gecko liked the method where the iframe was created earlier and THEN location.replace was used. I'll probably be rewriting the class to use the location.replace method EXCEPT on opera since that is the browser that failed with the method (strangely enough IE works with both methods) - and opera is probably the EASIEST to detect for (window.opera you are my friend).

There are some other random errors yet, but the iframe implementation on browsers is so DIFFERENT and so different even between versions that making one that works for everything is a real pain in the butt.

In addition to all this mess, you have people who don't know what they're doing turning Firefox 1.5's strict javascript checking on - the problem is several of the "strict" warnings it uses will make scripts FAIL in IE 5.0 - a bit more on the subject.

Comments

Be the first to write a comment!

Post a Reply