是否可以使用iframe而不链接另一页

问题描述:

这是经典的iframe代码。我想要的是当你点击不同的链接时显示不同的东西。是否可以使用iframe而不链接另一页

我想在不同链接的页面上在wordpress中显示不同的画廊。我不想代码不同的HTML的为他们每个人

<iframe id="myIframe" src="about:blank" height="200" width="500"></iframe> 
<br /> 
<a href="http://www.blogger.com" target="myIframe">Blogger</a><br /> 
<a href="http://www.cnn.com" target="myIframe">CNN</a><br /> 
<a href="http://www.google.com" target="myIframe">Google</a><br /> 
+0

如果你只是想显示的字的博客我没有看到在使用'iframe'的理由第一名 – PeeHaa 2012-04-19 21:52:42

+0

我想在不同链接的页面上在wordpress中显示不同的画廊。我不想为他们每个人编码不同的html。 – Reis 2012-04-19 21:54:17

的是什么,你正在试图做的是显示和隐藏一个链接,当点击该页面的特定部分。你不需要为此使用iframe。我想你最好使用隐藏的div,或者甚至可以使用ajax来加载不同的画廊。我会告诉你隐藏的div的方法:

<div id="gallery1" class="gallery"> 
    A whole lot of html that makes up the 1st gallery 
</div> 
<div id="gallery2" class="gallery" style="display:none"> 
    A whole lot of html that makes up the 2nd gallery 
</div> 
<div id="gallery3" class="gallery" style="display:none"> 
    A whole lot of html that makes up the 3nd gallery 
</div> 

<a href="JavaScript:void(0)" data-gallery="gallery1">Show gallery 1</a> 
<a href="JavaScript:void(0)" data-gallery="gallery2">Show gallery 2</a> 
<a href="JavaScript:void(0)" data-gallery="gallery3">Show gallery 3</a> 

​ 
$('a').click(function() { 
    $('.gallery').hide(); 
    $('#' + $(this).data('gallery')).show(); 
}); 

这里有一个js小提琴:http://jsfiddle.net/nV5vy/

+0

我想要在不同链接的页面上在wordpress中显示不同的画廊。我不想为他们每个人编码不同的html。 – Reis 2012-04-19 21:55:45

+0

啊我现在明白了这个问题,让我看看 – koenpeters 2012-04-19 21:57:37

+0

你能把它放在http://jsfiddle.net/上吗? – Reis 2012-04-19 22:00:16