我正在使用WordPress并使用jQuery fancyBox来显示YouTube视频,但出现此错误:
XMLHttpRequest cannot load http://www.youtube.com/embed/L9szn1QQfas?autoplay=1. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
我在footer.php中添加了波纹管
jQuery code
$(document).ready(function() {
$(".fancybox").fancybox();
});
并在我的帖子中添加了下面的html代码。
<a class="fancybox fancybox.iframe" href="http://www.youtube.com/embed/L9szn1QQfas?autoplay=1">
<img class="alignleft size-thumbnail wp-image-583" alt="small-screen-youtube" src="http://localhost/example/wp-content/uploads/2013/10/small-screen-youtube-150x150.png" width="150" height="150" />
</a>
这个问题杀了我:(
有什么想法或建议吗?谢谢。
最佳答案
<a class="fancybox fancybox.iframe" href="http://www.youtube.com/embed/L9szn1QQfas?autoplay=1">
<img class="alignleft size-thumbnail wp-image-583" alt="small-screen-youtube" src="http://localhost/example/wp-content/uploads/2013/10/small-screen-youtube-150x150.png" width="150" height="150" />
</a>
解决此问题所需要做的就是:将'fancybox.iframe'更改为'fancybox iframe'-删除dot(.),这对我有用。
关于php - jQuery fancyBox YouTube视频不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19463197/