我在iframe中收到未定义的错误 [英] I get an undefine error in iframe
本文介绍了我在iframe中收到未定义的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下面有一个iframe:
I have an iframe below:
<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe>
我正在尝试在下面停止命令,但始终收到未定义的错误:
I am trying to stop a command below but I keep getting an undefined error:
$('.upload_target').contentwindow is undefined
如何解决此未定义的错误?
How can I fix this undefined error?
下面是代码:
$(".uploadbutton").click(function() {
$(".upload_target").contentWindow.stop(); //for anything but IE
$(".upload_target").contentWindow.document.execCommand("Stop"); // for IE
return stopImageUpload();
});
推荐答案
您会得到undefined
,因为contentWindow
是本机Javascript,并且您正在jQuery集合中使用它,而没有contentWindow
作为价值.您必须先获取原始的DOM对象.改为执行此操作:
You get undefined
because contentWindow
is native Javascript and you're using it on a jQuery collection, which doesn't have contentWindow
as a value. You have to get the original DOM object first. Do this instead:
$('.upload_target').get(0).contentWindow
这篇关于我在iframe中收到未定义的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文