我正在使用 3 个图片库。当您单击图像时,会出现一个弹出窗口,其中包含一个 iframe。目前,单击时的 3 个不同图像都在弹出窗口中显示相同的视频。我想知道如何为不同的图像调用不同的视频。另外,是否可以自动启动视频,这样您就不必在弹出窗口出现时按播放?谢谢大家,我的代码如下。
<script>
$(document).ready(function() {
$('a.login-window').click(function() {
//Getting the variable's value from a link
var loginBox = $(this).attr('href');
//Fade in the Popup
$(loginBox).fadeIn(300);
//Set the center alignment padding + border see css style
var popMargTop = ($(loginBox).height() + 24) / 2;
var popMargLeft = ($(loginBox).width() + 24) / 2;
$(loginBox).css({
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft
});
// Add the mask to body
$('body').append('<div id="mask"></div>');
$('#mask').fadeIn(300);
return false;
});
// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() {
$('#mask , .login-popup').fadeOut(300 , function() {
$('#mask').remove();
});
return false;
});
});
</script>
<div id="videos">
<div id="header_start">
<a class="login-window" href="#login-box"><img src="/images/video_holder1.jpg" style="padding-right: 20px; width: 316px; height: 186px;" /></a></div>
<div class="login-popup" id="login-box">
<iframe width="560" height="315" src="foo.com" frameborder="0" allowfullscreen></iframe>
<a class="close" href="#"><img alt="Close" class="btn_close" src="close_pop.png" title="Close Window" /></a>
</div></div>
<div id="videos1">
<div id="header_start">
<a class="login-window" href="#login-box"><img src="/images/video_holder2.jpg" style="padding-right: 20px; width: 316px; height: 186px;" /></a></div>
<div class="login-popup" id="login-box">
<iframe width="560" height="315" src="foo.com" frameborder="0" allowfullscreen></iframe>
<a class="close" href="#"><img alt="Close" class="btn_close" src="close_pop.png" title="Close Window" /></a>
</div></div>
<div id="videos2">
<div id="header_start">
<a class="login-window" href="#login-box"><img src="/images/video_holder3.jpg" style="padding-right: 20px; width: 316px; height: 186px;" /></a></div>
<div class="login-popup" id="login-box">
<iframe width="560" height="315" src="foo.com" frameborder="0" allowfullscreen></iframe>
<a class="close" href="#"><img alt="Close" class="btn_close" src="close_pop.png" title="Close Window" /></a>
</div></div>