Skip to content

Commit 223bc24

Browse files
author
Dave Gurnell
committed
Start fixing #214 - workaround for bug in IE8 iframe onload implementation
IE8 doesn't honour onload listeners attached using Javascript. See: http://stackoverflow.com/questions/12910534/why-doesnt-ie8-handle-iframe-onload-events This commit attaches the handler using HTML instead. A further commit will be needed to reorder the code to avoid a race condition where the iframe is initialized before the handler is setup.
1 parent f4c59fd commit 223bc24

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/FileAPI.XHR.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979

8080
_send: function (options, data){
81-
var _this = this, xhr, uid = _this.uid, url = options.url;
81+
var _this = this, xhr, uid = _this.uid, onloadFuncName = _this.uid + "Load", url = options.url;
8282

8383
api.log('XHR._send:', data);
8484

@@ -98,7 +98,7 @@
9898

9999
xhr = document.createElement('div');
100100
xhr.innerHTML = '<form target="'+ uid +'" action="'+ url +'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;">'
101-
+ '<iframe name="'+ uid +'" src="javascript:false;"></iframe>'
101+
+ '<iframe name="'+ uid +'" src="javascript:false;" onload="' + onloadFuncName + '()"></iframe>'
102102
+ (jsonp && (options.url.indexOf('=?') < 0) ? '<input value="'+ uid +'" name="'+jsonp+'" type="hidden"/>' : '')
103103
+ '</form>'
104104
;
@@ -140,7 +140,7 @@
140140
_this.end(status, statusText);
141141

142142
api.event.off(window, 'message', onPostMessage);
143-
window[uid] = xhr = transport = transport.onload = null;
143+
window[uid] = xhr = transport = window[onloadFuncName] = null;
144144
}
145145
;
146146

@@ -156,7 +156,7 @@
156156

157157
api.event.on(window, 'message', onPostMessage);
158158

159-
transport.onload = function (){
159+
window[onloadFuncName] = function (){
160160
try {
161161
var
162162
win = transport.contentWindow
@@ -373,7 +373,7 @@
373373

374374
}
375375
} else {
376-
// FormData
376+
// FormData
377377
xhr.send(data);
378378
}
379379
}

0 commit comments

Comments
 (0)