问题
Site: http://blieque.comli.com/motion
Before I start, I know there are many alternatives to Lightbox2 (Lokesh Dhakar's) to display videos but I want to avoid using three different JavaScript things, already using MooTools and JQuery as I'd like to keep HTTP requests to a minimum, as well as disk usage.
As it comes, Lightbox2 does not support videos, full stop. However, I noticed that the JavaScript was essentially taking the contents of an a
's href
attribute and placing it in an img
's src
attribute when the light-box was open. As far as I can see, changing this img
to an iframe
(done) and setting the anchor tag's href
to youtube.com/embed/*video-id*
should generate an iframe
containing that YouTube video (replacing watch?id=
with embed/
presents a full screen version of the video.
I then also added JavaScript for width, height and frameborder attributes on top of the default class="lb-image"
. Now when the page is loaded and the Lightbox called it creates an empty window. If you inspect the code you can see all the attributes are there but the page in the frame frame isn't loaded, just creating an empty head
and body
tag.
I was just wondering if it was a server problem or a code problem and if so, how to fix it. If there any way to make it work?
Thanks
Note: I'm NOT using Drupal so the lightvideo
option is not available.
回答1:
Enabling video support
By default, support for videos is disabled. However, this can be easily enabled by checking the enable video support option on admin/settings/lightbox2.
Basic Example
<a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo">This Video</a>
Reference
来源:https://stackoverflow.com/questions/11548589/using-lightbox2-to-display-video