0

What I Need:

  • when user click on video url it must redirected to you video.
  • we are using html5lightbox plugin .

problem im facing:

  • redirection is not working in iframe.
  • though when i click on src of iframe it is redirected to you tube url.

here is html code

   <div id="html5lightbox-web" style="display:block;width:500px;height:400px;">

     <iframe width="500" height="400" src="http://t.co/hNLWmspb" frameborder="0">

        </iframe></div>
  • i have tested on chrome its not auto redirected t particular page url.

problem explanation

  • when user click on image video should be opened .

tweet data

    VW @ European Motor Show Brussels - Behind the scene (part 1): &nbsp;<a class="twtlnk" rel="nofollow" href="http://youtu.be/XzqagJTsNrc" target=\"_blank\">http://youtu.be/XzqagJTsNrc</a>  via &nbsp;<a class="twthand" href="https://twitter.com/youtube" rel="nofollow" target=\"_blank\" >@youtube</a>

here is code snippet

                 $media_url;// http://t.co/hNLWmspb




               $parsed = parse_url($media_url);
                print_r($parsed);

               Array ( [scheme] => http [host] => t.co [path] => /hNLWmspb 

                $ytarray=explode("/", $media_url);
                $ytendstring=end($ytarray);
                $ytendarray=explode("?v=", $ytendstring);
                $ytendstring=end($ytendarray);
                $ytendarray=explode("&", $ytendstring);
                $ytcode=$ytendarray[0];
                print_r($ytcode);

                if(preg_match('/http:\/\/(www\.)*youtube\.com\/.*/',$parsed['path']))
                {
                       // echo "YouTube URL found!\n";
                    $content='<div class="4u"><div class="box photo tile">
                 <a href='.$media_url.' class="html5lightbox" data-group=""
                   titl="'.$tweet_content.'">';
                }

                else
                {
                    $content='<div class="4u"><div class="box photo tile">
                    <a href="http://www.youtube.com/embed/""'.$ytcode.' class="html5lightbox" data-group=""
                      titl="'.$tweet_content.'">';
                }
Community
  • 1
  • 1
user2818060
  • 835
  • 5
  • 19
  • 41
  • what do you mean by auto redirect? You don't have any link there, all you got is an iframe which includes youtube. Not quite sure if i understand what you're trying to do – Jeredepp Oct 08 '14 at 08:20
  • issue is that when i click on html lightbox div . it does not redirect t you tube url . – user2818060 Oct 08 '14 at 08:25

1 Answers1

1

The server for the URL that http://t.co/hNLWmspb redirects to returns

x-frame-options:SAMEORIGIN

in the HTTP response headers for the document you are trying to display in the frame.

This bans other sites (including yours) from showing the page in a frame, so the browser isn't rendering the page.

Use the official YouTube embed code instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335