重定向网址不适用于iframe

时间:2014-10-08 08:16:22

标签: html redirect iframe

我需要的是什么:

  • 当用户点击视频网址时,它必须重定向到您的视频。
  • 我们正在使用html5lightbox插件。

面临的问题:

  • 重定向在iframe中不起作用。
  • 虽然当我点击iframe的src时,它会被重定向到你的管网址。

这里是html代码

   <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>
  • 我在chrome上测试过它没有自动重定向的特定页面网址。

问题解释

  • 当用户点击图片视频时应该打开。

推特数据

    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>

这是代码段

                 $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.'">';
                }

1 个答案:

答案 0 :(得分:1)

http://t.co/hNLWmspb重定向到的网址的服务器返回

x-frame-options:SAMEORIGIN

在您尝试在框架中显示的文档的HTTP响应标题中。

这禁止其他网站(包括您的网站)在框架中显示该网页,因此浏览器无法呈现该网页。

使用官方YouTube嵌入代码。

相关问题