Ich habe eine WordPress-Site, auf der Beiträge in einen Iframe geladen werden.
Dies ist der Code, der funktioniert:
<a class="trick" rel="https://stackoverflow.com/questions/9538886/<?php the_permalink() ?>" href="https://stackoverflow.com/questions/9538886/<?php the_permalink() ?>"><?php the_title(); ?></a>
$(Dokument).ready(Funktion(){
$.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>
Wie kann man nun diesen geladenen Iframe aus dem Iframe heraus schließen?
Die Hauptseite ist index.php (Haupt-Wordpress-Schleife), der Inhalt des Iframes ist single.php (einzelner Beitrag) ohne Kopf- und Fußzeile.
Vielen Dank.
Das habe ich in 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 schließen? Wie meinst du das? Möchten Sie den inneren Iframe entfernen oder was?
– Reza Owliaei
2. März 2012 um 19:06 Uhr
Mögliches Duplikat von So schließen Sie einen Iframe innerhalb des Iframes selbst
– Oleg W. Wolkow
13. Juli 2016 um 22:43 Uhr