這是他們如何在工作中上燈箱呼叫選擇了iframe BODY元素
$(".lightbox873x560").colorbox({width:"845", height:"555", resize:false, iframe:true, scrolling:"no", opacity:"0.65"});
$(".lightboxGallery").colorbox({width:"845", height:"555", resize:false, iframe:true, scrolling:"no", opacity:"0.65"});
等定義的收藏夾..
的,這是我的建議
$(".lightboxCustom").colorbox({
width: $(this).attr('lWidth'), height: $(this).attr('lHeight'), resize:false, iframe:true, scrolling:"no", opacity:"0.65"
});
這方式的屬性lWidth,lHeight將決定colorbox的尺寸,
問題在於在裝conent,對身體會有另一預先定義將修復燈箱內容寬度類..
因此,如何我可以刪除嗎?
我看到顏色框得到這個額外參數:
$(".lightboxCustom").colorbox({
width: $(this).attr('lWidth'), height: $(this).attr('lHeight'), resize:false, iframe:true, scrolling:"no", opacity:"0.65",
onOpen:function(){ alert('onOpen: colorbox is about to open'); },
onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); }
});
所以什麼方法? onComplete,對不對?以及我如何找到/選擇身體?
與努力:
onComplete:function(){
console.log($('#cboxIframe').length);
console.log($('#colorbox #cboxWrapper #cboxLoadedContent iframe').length);
}
但兩者日誌0,是具有IFRAME類..
編輯
現在這是最接近我一直:
$(".lightboxCustom").each(function(){
$(this).colorbox({width: $(this).attr('lWidth'), height: $(this).attr('lHeight'), resize:false, iframe:true, scrolling:"no", opacity:"0.65",fastIframe:false,
onComplete:function(){
$(document).bind('cbox_complete',function(){
var iframe = $('#colorbox div#cboxWrapper div div#cboxContent div#cboxLoadedContent iframe#cboxIframe');
var body = iframe.contents().find('body');
console.log(iframe.length); /// ---> 1!!
console.log(body.lenght); /// ---> 1 :(
/*But the problem is that this is empty*/
alert(body.attr('class')); /*when its not*/
})
}
});
});
是$域( 「lightboxCustom」)鏈接從您的網站域名有什麼不同? – 2012-02-28 10:55:24
不,其相同的域 – 2012-02-28 20:19:55