I am using php to create youtube thumbs and need to open youtube video with fancybox calling it inside iframe. fancybox 2 FAQ tells:
Can the script be called from an iframe? If all necessary files are included in the parent window, then you can, like:
<a href="javascript:parent.$.fancybox.open({href : 'myurl'});">Open something</a>
So I did that and my fancybox actually opens as intended from iframe to parent window. Only problem is that instead of video it tells that "The requested content cannot be loaded. Please try again later" - reason for that is probably problems with http:address and I cant see where the script error is.
script I am using to create link in Iframe:
...some php here...
echo('
<div class="tube"><a title="'.$title.'" href="javascript:parent.Mybox.fancybox.open ({href : \'http://www.youtube.com/v/'.$v.'? feature=player_embedded&version=2&autohide=1&hd=1&modestbranding=1&rel=0&border=0&autoplay=0&fs=1&fmt=22 \'});"><img style="border:2px solid #000;margin:5px;" alt="'.$title.'" src="http://i1.ytimg.com/vi/'.$v.'/default.jpg"/></a>');
...some more php here...
The result it produces looks like this
<div class="tube"><a title="MyTitle" href="javascript:parent.Mybox.fancybox.open({href : 'http://www.youtube.com/v/J0_5JEJdB5g?feature=player_embedded&version=2&autohide=1&hd=1&modestbranding=1&rel=0&border=0&autoplay=0&fs=1&fmt=22 '});"><img style="border:2px solid #000;margin:5px;" alt="MyVideo" src="http://i1.ytimg.com/vi/J0_5JEJdB5g/default.jpg"/></a><p>09.11.2012<br/>MyVideo<br/>213times</p></div>
So what I`m doing wrong? What is wrong with 'myurl' or my fancybox settings?
My fancybox settings are:
<script type="text/javascript">
Mybox(document).ready(function() {
Mybox('#tubeframe')
.attr('rel', 'media-gallery')
.fancybox({
openEffect : 'elastic',
closeEffect : 'fade',
prevEffect : 'none',
nextEffect : 'none',
padding : 0,
autoScale : true,
fitToView : true,
height : 475,
width : 846,
fixed : true,
arrows : false,
helpers : {
media : {},
buttons : {},
title: {
type: 'outside'
},
overlay : {
opacity: 0.7,
css : {
'background-color' : '#433'
}
}
}
});
});
</script>