Fancybox回归”无法加载请求的内容。请稍后再试。”
使用 Fancybox 来在模式框中播放 YouTube 视频。
我的问题是我不断收到“无法加载请求的内容。请稍后重试。”
模式框弹出,所以我知道脚本正在运行,这可能是我的 API 调用有问题...这是我的调用:
<script type="text/javascript">
$(document).ready(function() {
/* This is basic - uses default settings */
$("a.fancybox").fancybox({
'hideOnContentClick': true
});
/* This is a non-obtrustive method for youtube videos*/
$("a[rel=fancyvideo]").fancybox({
overlayShow: true,
frameWidth:640,
frameHeight:360,
});
});
</script>
Using Fancybox to play youtube videos in a modal box.
My Problem is that I keep getting "The requested content cannot be loaded. Please try again later."
The modal box is popping up so I know the script is running, it might be a problem with my API call... here is my call:
<script type="text/javascript">
$(document).ready(function() {
/* This is basic - uses default settings */
$("a.fancybox").fancybox({
'hideOnContentClick': true
});
/* This is a non-obtrustive method for youtube videos*/
$("a[rel=fancyvideo]").fancybox({
overlayShow: true,
frameWidth:640,
frameHeight:360,
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否有同时包含
class="fancybox"
和rel="fancyvideo"
的?如果这样做,那么您将两次将 Fancybox 绑定到这些元素,而 Fancybox 可能不喜欢这样。尝试取出这个:
然后看看仅使用第二个会发生什么。
更新:奇怪。该演示 (http://chadly.net/demos/video-lightbox.html) 生成的 HTML 与您的页面不同,演示构建了一个
在您的 Fancybox 绑定中,这就是
内容的来源。但是,href
指向普通的旧 YouTube 视频观看 HTML 页面,并且href
最终作为< 的
。用于嵌入 YouTube 视频的 URL 与视频的 HTML 页面不同,这可能是问题的根源。src
属性;嵌入>的
href
替换为:尝试将如下所示
第一个是 YouTube 的纯 HTML 页面,第二个是可嵌入的 SWF。
更新 2:您使用的示例适用于 Fancybox 1.0.0,但您使用的是 1.3.4,1.0.0 对 YouTube 进行了一些特殊检查,这些检查在更高版本中不存在:
这是从 1.0.0 开始的,
else if
之后的代码将 HTML 页面 URL(例如http://www.youtube.com/watch?v=QmVvgSfdmJQ
)重写为旧的可嵌入 SWF URL(例如http://www.youtube.com/v/QmVvgSfdmJQ
)。此版本问题还解释了为什么演示生成的 HTML 与您的不同。因此,除了其他问题之外,您还存在一些版本问题。
Do you have any
<a>
s with bothclass="fancybox"
andrel="fancyvideo"
? If you do then you'll be binding Fancybox to those elements twice and Fancybox might not like that. Try taking out this one:And see what happens with just the second one in place.
UPDATE: Strange. The demo (http://chadly.net/demos/video-lightbox.html) is producing different HTML than your page, the demo builds an
<object data=...>
but yours builds a<object><embed src="youtube-url">
thing. You're saying:in your Fancybox binding, that's where the
<object><embed>...</embed></object>
stuff comes from. However, thehref
points at a plain old YouTube video viewing HTML page and thathref
ends up as thesrc
attribute for the<embed>
. The URL for embedding a YouTube video isn't the same as the video's HTML page and that's probably the source of your problem.Try replacing the
href
that looks like this:with one like this:
The first is the plain HTML page for YouTube, the second is the embeddable SWF.
UPDATE 2: The example you're working from is for Fancybox 1.0.0 but you're using 1.3.4, 1.0.0 has some special checks for YouTube that aren't present in later versions:
That's from 1.0.0 and the code after that
else if
rewrites the HTML page URL (e.g.http://www.youtube.com/watch?v=QmVvgSfdmJQ
) to the older embeddable SWF URL (e.g.http://www.youtube.com/v/QmVvgSfdmJQ
). This version problem also explains why the demo was producing different HTML than your's.So, you have some version problems on top of everything else.
检查您是否已包含 jquery.fancybox-media.js
Check if you have included the jquery.fancybox-media.js
看起来您的代码可能略有偏差
http://chadly .net/post/2009/01/29/Lightbox-for-YouTube-Videos.aspx
Looks like your code might be slightly off
http://chadly.net/post/2009/01/29/Lightbox-for-YouTube-Videos.aspx
使用此示例不要忘记 href
use this sample don't forget href