У меня есть сайт Wordpress, где сообщения загружаются в iframe.Как закрыть iframe изнутри iframe?
Это код, который работает:
<a class="trick" rel="<?php the_permalink() ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
$ (документ) .ready (функция() {
$.ajaxSetup({cache:false}); $(".trick").click(function(){ var post_link = $(this).attr("rel"); $("#frame").css("display","block"); $("#frame").attr("url", post_link); $("body").css("overflow","hidden"); }); }); </script>
<iframe id="frame" frameborder="no" allowtransparency="true" width="100%" height="100%" scrolling="no" src=""></iframe>
Теперь, как закрыть этот нагруженный iframe изнутри iframe?
Главная страница - index.php (основной цикл wordpress), содержимое iframe - single.php (одно сообщение) без заголовка и нижнего колонтитула.
Спасибо.
Это то, что я получил в single.php
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#close").click(function(){
$('#frame', window.parent.document).remove();
});
});
</script>
</head>
<body>
<div id="container-single">
<button id="close" >Close</button>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article <?php post_class('single') ?> id="post-<?php the_ID(); ?>">
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
<?php the_tags('Tags: ', ', ', ''); ?>
<?php include (TEMPLATEPATH . '/_/inc/meta.php'); ?>
</div>
</article>
<?php endwhile; endif; ?>
</div>
</body>
Закрытие iframe? Что вы имеете в виду? Вы хотите удалить внутренний iframe или что? –
Возможный дубликат [Как закрыть iframe внутри самого iframe] (http://stackoverflow.com/questions/6754935/how-to-close-an-iframe-within-iframe-itself) –