Can't Write To Iframe In Ff Or Ie, Only Chrome
If you run this jsfiddle in CHrome, it will work, but on IE and FF it fails: http://jsfiddle.net/LbFPu/2/ I imagine it has something to do on how each engine writes into the DOM? I
Solution 1:
That's just because you're trying to write to an iframe that's not loaded yet, seems chrome is faster :
$('body').append('<iframe id="upload"></iframe>');
var form = $('<form enctype="multipart/form-data" id="image_upload" action="index.php">'
+ '<input type="file" accept="image/*" multiple name="img[]" id="image" />'
+ '<br>'
+ '<input type="submit" value="Upload images" class="upload" />'
+ '</form>');
$('#upload').on('load', function() {
$(this).contents().find('body').append(form);
});
Solution 2:
In FF, if you add a setTimeout()
around the last line of the fiddle it works:
$('body').append('<iframeid="upload"></iframe>');
var form = $('<formenctype="multipart/form-data"id="image_upload"action="index.php">' +
'<inputtype="file"accept="image/*"multiplename="img[]"id="image" />' + '<br>' +
'<inputtype="submit"value="Upload images"class="upload" />' + '</form>');
setTimeout(function () {
$('#upload').contents().find('body').append(form);
}, 100);
Post a Comment for "Can't Write To Iframe In Ff Or Ie, Only Chrome"