如何使用Thickbox显示视频



我正在尝试使用thickbox在页面上显示视频。按照网站上的说明操作,但当我点击链接时,它只会把我带到youtube页面,这不是我想要的。

我的头中有对jquery和thickbox的调用,以及thickbox:的css

<script src="<?php bloginfo('template_url'); ?>/javascripts/thickbox.js"></script>
<script src="<?php bloginfo('template_url'); ?>/javascripts/jquery.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/stylesheets/thickbox.css">

这是正文中的代码:

<strong>
<a class="thickbox" href="//www.youtube.com/embed/########?rel=0?KeepThis=true&TB_iframe=true&height=400&width=600"  title="##### Hanson">
    <img src="http://www.#########.org/campaign/wp-content/uploads/sites/59/2013/09/#####.jpg"/>
</a> ##### Hanson*<br>(1960 B.S.M.E.)
</strong>

为了隐私起见,我对上面代码中的一些信息进行了散列处理。有什么建议吗?

编辑:可能应该提到我在word press 中使用了这个

您需要加载ThickBox <script />AFTERjQuery文件。。。就像下面的代码一样。

EDIT:另外,将您的jQuery脚本替换为CDN jQuery版本,我在示例中使用了该版本。然后清除浏览器cache(使用WP时很重要)。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/javascripts/thickbox.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/stylesheets/thickbox.css">

根据经验,jQuery <script />应该始终是列出的第一个js文件。它需要先加载,然后再加载其他js脚本(假设其他脚本需要jQuery)。否则,它们将不会被启动。

最新更新