<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- 视口设置,对移动设备的支持 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>在模态框里动态赋值视频</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
<a href="#" onclick="modalhk('A','http://e66f8c914d40.mp4')">开始演示模态框11</a>
<a href="#" onclick="modalhk('B','http://3caf49.mp4')">开始演示模态框22</a>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close">
×
</button>
<h4 class="modal-title" id="myModalLabel">
</h4>
</div>
<div class="modal-body">
<video src="" controls="controls" autoplay="autoplay" id="myVideo" width="100%" height="100%" >
Your browser does not support the video tag.
</video>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
<script>
function modalhk(title,src)
{
$("#myModalLabel").html(title);//动态复制到模态框标题
$("#myVideo").attr("src",src); //动态赋值到VIDEO的SRC
$('#myModal').modal("show");//打开模态框
}
$(function() {
//var video = document.getElementById("myVideo");
//激活弹出框
//$('[data-toggle="popover"]').popover();
//模拟点击播放视频按钮
//$(document).ready(function() {
//$("#myButton").click();
//})
//模态框
$("#myModal").modal({
show:false,
// remote:"demo33_modal.html",//载入某个页面的内容
backdrop:"static", //设置static时点击外部区域不会关闭模态框,但"static"提供了与true相同的灰色背景
//keyboard: true //按下esc时,退出模态框,必须设置tabindex=-1
})
//点击关闭按钮时,暂停视频
$("#close").click(function() {
document.getElementById("myVideo").pause();
video.pause();
});
setInterval(function() {
if(video.paused) {
$('[data-toggle="popover"]').popover("show");
}else {
$('[data-toggle="popover"]').popover("hide");
}
},2000);
});
</script>
</div>
</div>
</div>
</body>
</html>
在Bootstrap 模态框里动态赋值视频
最新推荐文章于 2021-08-21 09:18:59 发布