Javascript 如何在单击时重新加载iframe?

Javascript 如何在单击时重新加载iframe?,javascript,jquery,dom,Javascript,Jquery,Dom,可能重复: 如何在单击事件中重新加载 我试过这个,但不起作用: jQuery("#link").click(function(){ jQuery('#iframeID')[0].reload(); }) 像这样 document.getElementById('iframeID').contentWindow.location.reload(); $('iframe').each(function() { this.contentWindow.location.reload(tr

可能重复:

如何在单击事件中重新加载

我试过这个,但不起作用:

jQuery("#link").click(function(){
   jQuery('#iframeID')[0].reload();
})
像这样

document.getElementById('iframeID').contentWindow.location.reload();
$('iframe').each(function() {
  this.contentWindow.location.reload(true);
});
或通过

document.getElementById('iframeID').src = document.getElementById('iframeID').src;

您可以这样做:

$("#iframe").attr('src', ($('#iframe').attr('src'));
每次单击带有
id=reload
的链接时,上述代码将重新加载页面中的每个iframe

感谢@Haim Evgi

或者你也可以这样做

$('iframe').each(function() {
  this.contentWindow.location.reload(true);
});

这可能已经是答案了[iframe Jquery reload][1][1]:感谢您的帮助,在我的所有modals中添加了一个“reload”类,其中包含视频,这非常有帮助,可以完美地处理它们。
var iframe = document.getElementById('ID');

iframe.src = iframe.src;