来自iFrame的Colorbox Load Specific div

ans*_*rob 1 jquery colorbox

我正在使用Colorbox,我想从网站上的另一个页面加载一个特定的div.现在我正在使用iFrame,但我想它不一定是iFrame,因为我留在同一个网站上.我的代码现在是:

$(document).ready(function(){
  $(".iframe").colorbox({iframe:true, data:"#mainColumn", width:"80%", height:"80%"});
});

<a class="iframe cboxIframe" href="http://website.com/products-51>.html">
Run Code Online (Sandbox Code Playgroud)

我需要将页面加载href到Colorbox中,但只显示#mainColumndiv.

Sha*_*oli 7

ColorBox利用jQuery的.load()方法来处理ajax.如果要从与当前文档相同的域中加载文档,则可以使用选择器仅拉出所需文档的一部分.我假设从其他页面你想要的容器是#mainColumn

var $iframe = $(".iframe");
$(".iframe").colorbox({ 
    href: $(".iframe").attr('href') + " #mainColumn",
});
Run Code Online (Sandbox Code Playgroud)