I have a page containing a couple of <iframe>
tags. I want to change their onload actions dynamically. I have the following code that works fine in FF, Safari, Chrome, Opera, but IE (8) refuses to ply.
document.getElementById('myiframe').onload = function() {
return function() { file_onLoad(data); }
}();
I've been using something similar for setting the onchange
of an <input>
element and this works well in all the browsers I've tested, including IE.
document.getElementById('myinput').onchange = function() {
return function() { file_onChange(data); }
}();
So I guess it has something to do with the way I'm getting the frame element / object.
I've also tried frames['myiframe']
but with no success.
Thanks for your help!
I have a page containing a couple of <iframe>
tags. I want to change their onload actions dynamically. I have the following code that works fine in FF, Safari, Chrome, Opera, but IE (8) refuses to ply.
document.getElementById('myiframe').onload = function() {
return function() { file_onLoad(data); }
}();
I've been using something similar for setting the onchange
of an <input>
element and this works well in all the browsers I've tested, including IE.
document.getElementById('myinput').onchange = function() {
return function() { file_onChange(data); }
}();
So I guess it has something to do with the way I'm getting the frame element / object.
I've also tried frames['myiframe']
but with no success.
Thanks for your help!
Share Improve this question asked Jul 20, 2011 at 16:36 Sorin ButurugeanuSorin Buturugeanu 1,8404 gold badges20 silver badges32 bronze badges1 Answer
Reset to default 7It works fine on mine...
I tried:
function whatever(){
document.getElementById('myiframe').src="http://www.google./"
document.getElementById('myiframe').onload = function() {
return function() { alert("Done."); }
}();
}
and it works. (I tried on IE9 with IE8 mode turned on)
If it does not work for you, try this:
document.getElementById('myiframe').addEventListener('load', file_onLoad, false);