Fix for Problems Using Lightwindow and submitting a form using AJAX in IE
I've been using lightwindow at work and we came across an issue where we needed to submit a form "into" the lightwindow iframe. I did a search and stumbled apon this article by Miguel Arroz which describes the issue for uploading images with AJAX.
Basically the issue is summed up like this: when creating an iframe element in IE using the javascript .createElement('iframe'); the iframe is created fine but it is not possible to assign it a name tag for some reason. In the case of lightwindow this made it impossible (in IE) to submit a form into the lightwindow. Instead it popped the content into a new window as it couldn't find its target. I would have put this on the lightwindow forums but they're apparently down currently!
The fix is as follows:
This meant a change of the lightwindow.js script (at ~ line 1146 to use Miguel's fix and create the lightwindow iframe like this:
//
// Add in iframe
//
_appendIframe : function(scroll) {
var iframe;
try {
iframe = document.createElement('');
} catch (ex) {
iframe = document.createElement('iframe');
}
iframe.setAttribute('id', 'lightwindow_iframe');
iframe.setAttribute('name', 'lightwindow_iframe');
iframe.setAttribute('src', 'about:blank');
iframe.setAttribute('height', '100%');
iframe.setAttribute('width', '100%');
iframe.setAttribute('frameborder', '0');
iframe.setAttribute('marginwidth', '0');
iframe.setAttribute('marginheight', '0');
iframe.setAttribute('scrolling', scroll);
This fixed the problem straight away. Thanks to Terminal.app
Until next time...
Dan
Bookmark this blog with:
What are these?