0

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>  
dogcat
  • 994
  • 7
  • 10
  • [Youtube does not allow embedding](http://stackoverflow.com/questions/8698742/cant-get-youtube-com-to-load-in-iframe-help-please) – moonwave99 Aug 23 '12 at 22:54
  • Have checked http://stackoverflow.com/a/8855410/1055987 ? – JFK Aug 24 '12 at 01:24
  • possible duplicate of [call Fancybox in parent from iframe](http://stackoverflow.com/questions/8853727/call-fancybox-in-parent-from-iframe) – JFK Aug 24 '12 at 01:24
  • In my case actually fancybox opens from child page seamlessly, no errors. It just does not open video file! Interesting is also that here stackoverflow.com/questions/8853727/call-fancybox-in-parent-from-iframe is not used fancybox official method href="javascript:parent.$.fancybox.open({href : 'myurl'});" - does this work at all? – dogcat Aug 24 '12 at 22:36

1 Answers1

0

After days of search found solution described here:

open iframe fancybox from within an iframe so that it opens in the parent

Its all about fancybox settings

Community
  • 1
  • 1
dogcat
  • 994
  • 7
  • 10