【问题标题】:How to close an iframe window?如何关闭 iframe 窗口?
【发布时间】:2016-01-13 06:15:16
【问题描述】:

大家好,现在我正在使用 iframe,问题是 iframe 没有完全关闭,而重新加载页面时 iframe 正在后台运行,并且由于 iframe 按钮导致重新加载后我无法访问页面我无法访问该页面。

我在下面附上了我的 iframe 代码建议我可能的解决方案。

<div class="top" onclick="removeIFrame();"></div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">New Message</h4>
      </div>
      <div class="modal-body">
        <iframe id="templatesrc" name="templatesrc" src="?do=manualupgrade&id=<AJDF:output>$smarty.get.id</AJDF:output>" width="690" height="400" frameborder="0"></iframe>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>            
      </div>
    </div>
  </div>
</div>

【问题讨论】:

  • removeIFrame(); 的代码是什么?
  • 我已经将它重新加载到另一个页面,需要它吗?
  • 对不起,我第一次在 i 框架中工作,我不知道是否需要它所以你能告诉我删除 IFrame 的代码

标签: javascript php jquery html iframe


【解决方案1】:

在您的页面中添加以下代码

<script>
function removeIFrame(){
document.getElementById("templatesrc").remove();
}
</script>

这将完全删除 iframe。

【讨论】:

  • 你能告诉我我应该把它放在哪里。我第一次在 iframe 中工作
  • 是的,通过设置按钮的点击功能来尝试您的代码
猜你喜欢
  • 1970-01-01
  • 2015-08-14
  • 1970-01-01
  • 1970-01-01
  • 2014-11-29
  • 1970-01-01
  • 2016-06-30
  • 2016-06-16
  • 1970-01-01
相关资源
最近更新 更多