[英]Why does I get the error “error undefine 'http…' is not a function”?
[英]I get an undefine error in iframe
我下面有一个iframe:
<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe>
我试图在下面停止命令,但我一直收到一个未定义的错误:
$('.upload_target').contentwindow is undefined
如何修复此未定义的错误?
以下是代码:
$(".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对象。 改为:
$('.upload_target').get(0).contentWindow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.