Colorbox - 如何仅显示特定DIV

时间:2012-06-12 10:23:24

标签: jquery colorbox

我正在使用Colorbox在电子商店中展示产品,但我只想展示产品div(#prodpreview),而不是整个页面有页眉,页脚等。

每个产品链接如下所示:

<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>

这是我对Colorbox的调用:

$("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"; }});

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

2 个答案:

答案 0 :(得分:7)

如果你想在colorbox中显示特定的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>

答案 1 :(得分:-2)

该div的正确脚本是:

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

假设它是一个id而不是一个类

相关问题