【问题标题】:How do I use Thickbox to display videos?如何使用Thickbox 显示视频?
【发布时间】:2013-11-25 19:45:55
【问题描述】:

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

我的标题中有对 jquery 和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 中使用它

【问题讨论】:

  • 旁注(与问题无关),您应该将&lt;strong /&gt; 放在##### Hanson*&lt;br&gt;(1960 B.S.M.E.) 周围,而不是锚本身。 ;)

标签: javascript jquery html css thickbox


【解决方案1】:

您需要加载ThickBox &lt;script /&gt; AFTER jQuery 文件...就像下面的代码。

编辑: 另外,将您拥有的 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 &lt;script /&gt; 应该始终是列出的第一个 js 文件。它需要在您的其他 js 脚本之前先加载(假设您的其余脚本需要 jQuery)。否则它们不会被启动。

【讨论】:

  • 我换了两个,但仍然不能正常工作。
  • 当您单击链接时...会发生什么?单击链接后,您会收到哪些控制台错误(在 Chrome 或 Firebug 中)?
  • 单击链接后,我在 chrome 中没有收到任何控制台错误,它只是将我带到 youtube 页面。不过,在我点击链接之前,控制台告诉我:Uncaught ReferenceError: $ is not defined thinbox.js:14
  • 在控制台输入$.fn.jquery,请告诉我结果。
  • 另外,请清除浏览器缓存,然后重试。你 100% 确定 jQuery 脚本在 thichbox.js 文件之上,对吧?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-08-07
  • 2011-09-09
  • 2018-10-28
  • 2019-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多