【问题标题】:How to close a full screen iframe?如何关闭全屏 iframe?
【发布时间】:2012-03-01 21:51:42
【问题描述】:

我有一个 wordpress 网站,它在一个 iframe 中加载帖子的内容,位置固定,宽度和高度为 100%。这是悬停所有网站...

我有一个关闭按钮;如何告诉按钮隐藏 iframe 并显示其下的内容?

附:对不起我的英语。

谢谢

<h2><a class="trick" rel="<?php the_permalink() ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

.

$(document).ready(function(){
  $.ajaxSetup({cache:false});
  $(".trick").click(function(){
    var post_link = $(this).attr("rel");
    $("#frame").attr("url", post_link);
    return false;
  });
});

【问题讨论】:

  • 如果你给我们一些代码,我们会原谅的
  • @LucaFrankGuarini 请更新您的问题而不是添加评论,我们会更容易阅读

标签: jquery wordpress iframe


【解决方案1】:

如果您想通过 iframe 中的按钮关闭 iframe,您将需要以下内容:

<button onclick="parent.window.location.hash ='close'">close</button>

这将更改您网址中的引用。例如:yourwebiste.com/yourpage.php#close
然后您需要检查何时使用类似这样的内容(在父文件中)调用此引用:

    var close_iframe = false;

setInterval(function(){

    if(!close_iframe){

        hash_val = window.location.hash;

        if (hash_arr[0] == "#close"){

            $(#iframe_id).hide();
            close_iframe = true;

        }
    }

  }, 100);

希望我说的够清楚,对你有帮助,对不起,这是我的第一个答案嘿嘿。

【讨论】:

  • 谢谢.. 第一行代码有效。 #close 被添加到 url。我在哪里插入第二部分?
猜你喜欢
  • 2022-12-03
  • 1970-01-01
  • 2011-09-03
  • 2014-09-06
  • 2017-03-31
  • 1970-01-01
  • 2018-08-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多