动态更改iframe的载入 [英] dynamically change onload for an iframe
问题描述
我有一个页面包含两个< iframe>
标签。我想动态地改变它们的负载动作。我有以下代码在FF,Safari,Chrome,Opera中都可以正常工作,但IE(8)拒绝遵守。
document.getElementById('myiframe')。onload = function(){
return function(){file_onLoad(data); }
}();
我一直在使用类似的东西来设置 onchange
< input> 元素,这在我测试过的所有浏览器中都有效,包括IE。
$ pre>
document.getElementById('myinput')。onchange = function(){
return function(){file_onChange(data); }
}();
所以我想这有东西我正在获取框架元素/对象的方式。
我也尝试过 frames ['myiframe']
但没有成功。
感谢您的帮助!
它的工作正常我的...
我试过:
function whatever() {
document.getElementById('myiframe')。src =http://www.google.com/
document.getElementById('myiframe')。onload = function(){
return function(){alert(Done。); }
}();
}
它的工作原理。 (我尝试IE9打开IE8模式)
如果它不适合你,请尝试:
document.getElementById('myiframe')。addEventListener('load',file_onLoad,false);
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 comply.
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!
It works fine on mine...
I tried:
function whatever(){
document.getElementById('myiframe').src="http://www.google.com/"
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);
这篇关于动态更改iframe的载入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!