2012-06-12 154 views
1

我使用Colorbox在电子商店中显示产品,但我只想显示产品div(#prodpreview),而不是整个页面,包含页眉,页脚等。Colorbox - 如何仅显示特定的DIV

每个产品的链接如下所示:

<a class="items" href="product.php?id=1" rel="items">Link to product 1</a> 
<a class="items" href="product.php?id=2" rel="items">Link to product 2</a> 

这是我的电话,以彩盒:

$("a.items").colorbox({rel: 'items', iframe:true, transition:"fade", 
width:"80%", height:"90%", 
onClosed:function(){ location.reload(true); } }); 

我读过this ,但它不会为我工作,任何其他建议?

更新:我已经改变了一些事情,现在我正在使用以下调用在Colorbox中打开一个页面并显示特定的div。

$('a.items').colorbox({ href:function(){ return this.href + " #prodpreview"; }}); 

但现在我已经失去了彩盒的所有iframe的能力,当我在颜色框提交表单,窗口关闭,我只剩下的产品页面。那么,如何从这里开始结合这两个功能,打开一个Colorbox窗口来显示一个#div,但也有iframe功能,以便我可以在Colorbox中提交表单?

+0

谢谢,我有一个类似的问题,你的更新帮助我! – Alvaro

回答

7

如果你想显示在颜色框具体的div,你应该做的:

<div id="prodpreview" style="display:none"> 
    your stuff here 
</div> 
<a class='inline' href="#prodpreview">Inline HTML</a> 

<script> 
$(".inline").colorbox({inline:true}); 
</script> 
+0

和来自外部URL的请求有关吗?他们将如何看到产品? – bikey77

-2

该DIV正确的脚本是:

<script>$("#inline").colorbox({inline:true});</script> 

Becose它是一个ID不是一类