javascript 如何使用 lightbox2 在我的页面中显示视频

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4691700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 14:33:22  来源:igfitidea点击:

how to use lightbox2 to show video in my page

javascripthtmllightbox

提问by humblePilgrim

First of all my site does not use Drupal.So any alternatives for a popup video player funcionality would be appreciated.

首先,我的网站不使用 Drupal。因此,对于弹出式视频播放器功能的任何替代方案都将不胜感激。

I want to show a popup you tube video player in my web page.I downloaded lighbox from the following link: http://ftp.drupal.org/files/projects/lightbox2-6.x-1.11.zip

我想在我的网页中显示一个弹出式管视频播放器。我从以下链接下载了灯箱: http://ftp.drupal.org/files/projects/lightbox2-6.x-1.11.zip

I extracted the zip file into my sites root

我将 zip 文件解压缩到我的网站根目录中

I added the following lines in my page header:

我在页眉中添加了以下几行:

<link type="text/css" rel="stylesheet" media="all" href="/lightbox2/css/lightbox.css?1" />

<script type="text/javascript" src="/lightbox2/js/auto_image_handling.js?1"></script>
<script type="text/javascript" src="/lightbox2/js/lightbox_video.js?1"></script>
<script type="text/javascript" src="/lightbox2/js/lightbox.js?1"></script>

and the following in the body:

以及正文中的以下内容:

<a href="http://www.youtube.com/watch?v=0gBtF_awV2o" rel=lightvideo[width:500px;height:400px;]>
    <img src="sample" alt="Live TV">
</a>

But the video opens up in a new tab and not as a popup.Where am i going wrong?I cant find tutorials for this anywhere, although i have this kind of code in many other pages with popup videos.

但是视频在新选项卡中打开而不是作为弹出窗口打开。我哪里出错了?我在任何地方都找不到相关教程,尽管我在许多其他带有弹出视频的页面中都有这种代码。

Edit:Used shadowbox. Opens up youtube page instead of popup!

编辑:使用阴影盒。打开 youtube 页面而不是弹出窗口!

Edit:Problem solved! Got Shadowbox to work. It's brilliant and easy. The commercial licence costs $20 though.

编辑:问题已解决!让 Shadowbox 工作。这是辉煌和容易的。不过,商业许可证的费用为 20 美元。

采纳答案by Trufa

You probably are either not calling jQuery or lighbox correctly.

您可能没有正确调用 jQuery 或 lightbox。

Make sure the have the two srccorrect.

确保两者src正确。

I'm not sure I understood your question but you cant display video with lightbox, it says so in the FAQ and it recommends thickbox.

我不确定我是否理解你的问题,但你不能用灯箱显示视频,它在常见问题解答中是这样说的,它推荐了thickbox

You could also use something videolighboxor any out there.

您也可以使用videolightbox或其他任何东西。

Good luck!

祝你好运!

回答by Trevor

I would download Lightbox 2 from hereand see if it works any better.

我会从这里下载 Lightbox 2,看看它是否更好用。

回答by Peter

The reason it doesn't work is because the lightbox.js file included in the Drupal module is a modified version that uses the Drupal.settings variable, which if you don't use Drupal, is undefined.

它不起作用的原因是 Drupal 模块中包含的 lightbox.js 文件是使用 Drupal.settings 变量的修改版本,如果您不使用 Drupal,则为undefined.

回答by user2699071

Lightbox2 video does work in drupal.

Lightbox2 视频在 drupal 中确实有效。

You have to enable video support in the lightbox2 settings The url: yourdrupal.com/admin/config/user-interface/lightbox2

您必须在 lightbox2 设置中启用视频支持网址:yourdrupal.com/admin/config/user-interface/lightbox2

The flv player should be empty if you don't have one.

如果你没有,flv 播放器应该是空的。