重定向URL不能与Iframe一起使用 [英] Redirect Url Is Not Working with Iframe
本文介绍了重定向URL不能与Iframe一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要的:
- 当用户点击视频网址时,它必须重定向到您的视频。
- 我们正在使用html5lightbox插件。
im im facing的问题:
这里是html代码
< div id =html5lightbox -webstyle =display:block; width:500px; height:400px;>
< / iframe>< / div>
- 我已经在chrome上测试了它的自动重定向t特定页面url。
问题解释
- 应该打开图片视频。
推特数据
VW @欧洲车展布鲁塞尔 - 幕后(第一部分):& nbsp;< a class =twtlnk =nofollowhref =http://youtu.be/XzqagJTsNrc target = \_blank\> http://youtu.be/XzqagJTsNrc< / a>通过& nbsp;< a class =twthandhref =https://twitter.com/youtube =nofollowtarget = \_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']))
{
// echoYouTube URL found!\\\
;
$ content ='< div class =4u>< div class =box photo tile>
< a $ h
else
{
$ content ='< div class =4u>< div class =box photo tile>
< a href =http://www.youtube.com/embed/'。$ ytcode。'class =html5lightboxdata-group =
titl ='。 $ t
$ b $ ul
$ b $我已经从如何在YouTube中嵌入YouTube视频?获得帮助。
解决方案
http:// t .co / hNLWmspb x-frame-options:SAMEORIGIN
在您尝试在框架中显示的文档的HTTP响应标头中。
禁止其他网站(包括您的网站)在框架中显示网页,因此浏览器不会呈现网页。
使用官方YouTube嵌入了代码。
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): <a class="twtlnk" rel="nofollow" href="http://youtu.be/XzqagJTsNrc" target=\"_blank\">http://youtu.be/XzqagJTsNrc</a> via <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.'">';
}
- i have taken help from How to embed YouTube videos in PHP?.
解决方案
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.
这篇关于重定向URL不能与Iframe一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文