Using FancyBox in a Facebook tab's iframe

1,000 views
Skip to first unread message

Jemaleddin Cole

unread,
Jun 8, 2011, 9:17:32 AM6/8/11
to fancybox
Hi there,

I read over the FAQs and the "Trying to set the position of the fancy
box" discussion from two years ago and didn't find anything k. super
helpful, so I thought I'd ask.

I'm trying to use a FancyBox in a custom iframe-style tab in Facebook
to load YouTube videos. The problem that I'm running into is that if I
call FancyBox from a link at the bottom or top of the iframe, the box
always pops up dead center - which is off screen. Evidently, in an
iframe that is sized to the height of its own HTML, there's no way to
really get the current scroll position. There were solutions proposed
in the previous discussion like changing the js or css to hardcode in
a value, but that doesn't do much much good as I'd like to call
FancyBox from the top and bottom of a rather long page.

Before I go messing with the code myself to add new options in, has
anyone already faced and solved this problem?

Alternatively, does anyone have a good recommendation for a different
way of doing the same thing? I worry that I'm overcomplicating this.

Thanks in advance,


Jemal Cole

Jemaleddin Cole

unread,
Jun 8, 2011, 10:51:33 AM6/8/11
to fanc...@googlegroups.com
So I solved my own problem. Here's the code:

$('.fancybox').each(function() {
var offset = $(this).offset();
var fbPosistion = offset.top - 200;
$(this).fancybox({
'type' : 'iframe',
'onComplete' : function(){
var fbCssText = $('#fancybox-wrap').css('cssText');
fbCssText = fbCssText + '; top: ' + fbPosistion + 'px !important;'
$('#fancybox-wrap').css('cssText', fbCssText);
}
});
});


Hopefully this helps somebody else.



Jemal Cole

Johan Guse

unread,
Dec 14, 2011, 5:15:55 PM12/14/11
to Jemaleddin Cole, fanc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages