Asp.net 模态 Window Javascript url 通过
Asp.net Modal Window Javascript url passing
我创建了一个脚本,它创建了一个旋转木马,可以在不同的图像中滑动。当我单击一个项目时,会显示一个新的模式 Window。
模式 window 包含链接到 youtube 视频的 iframe。
问题是我想根据用户在轮播中点击的内容更改为 url 所需的 YouTube 视频。我可以粘贴点击的 ID,但我不知道如何更改 iframe。 javascript.
仍是初学者
这是我的代码
函数 handleLeftClick(id) {
var a = $("#testvid" +id).attr('src');
警报(一);
};
// When the player is ready, add listeners for finish, and playProgress
player.addEvent('ready', function () {
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);
});
function onFinish(id) {
$('#myCarousel').carousel('pause');
// $('#myCarousel').carousel('play');
}
function onPlayProgress(data, id) {
$('#myCarousel').carousel('pause');
}
// invoke the carousel
$('#myCarousel').carousel({
interval: 1000,
pause: "hover"
});
//Modal Window
$(document).ready(function () {
/* Get iframe src attribute value i.e. YouTube video url
and store it in a variable */
var url = $("#myModal").attr('src');
/* Assign empty url value to the iframe src attribute when
modal hide, which stop the video playing */
$("#myModal").on('hide.bs.modal', function () {
$("#youtubeVideo").attr('src', '');
});
/* Assign the initially stored url back to the iframe src
attribute when modal is displayed again */
$("#myModal").on('show.bs.modal', function () {
$("#cartoonVideo").attr('src', url);
});
});
$('.activate_modal').click(函数(){
//get the id of the modal window stored in the name of the activating element
// var modal_id = $(this).attr('name');
//use the function to show it
//show_modal(modal_id);
alert("Hello! I am an alert box!!");
});
</script>
×
Youtube 视频
要解决问题,请在 handleleftClick 中添加此内容
$(".modal-body").html('<iframe id="youtubeVideo" width="100%" height="350px" frameborder="0" scrolling="no" src=" ' + a + '?html5=1"; " allowtransparency="true" allowfullscreen ></iframe>');
我创建了一个脚本,它创建了一个旋转木马,可以在不同的图像中滑动。当我单击一个项目时,会显示一个新的模式 Window。 模式 window 包含链接到 youtube 视频的 iframe。
问题是我想根据用户在轮播中点击的内容更改为 url 所需的 YouTube 视频。我可以粘贴点击的 ID,但我不知道如何更改 iframe。 javascript.
仍是初学者这是我的代码
函数 handleLeftClick(id) { var a = $("#testvid" +id).attr('src'); 警报(一); };
// When the player is ready, add listeners for finish, and playProgress
player.addEvent('ready', function () {
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);
});
function onFinish(id) {
$('#myCarousel').carousel('pause');
// $('#myCarousel').carousel('play'); }
function onPlayProgress(data, id) {
$('#myCarousel').carousel('pause');
}
// invoke the carousel
$('#myCarousel').carousel({
interval: 1000,
pause: "hover"
});
//Modal Window
$(document).ready(function () {
/* Get iframe src attribute value i.e. YouTube video url
and store it in a variable */
var url = $("#myModal").attr('src');
/* Assign empty url value to the iframe src attribute when
modal hide, which stop the video playing */
$("#myModal").on('hide.bs.modal', function () {
$("#youtubeVideo").attr('src', '');
});
/* Assign the initially stored url back to the iframe src
attribute when modal is displayed again */
$("#myModal").on('show.bs.modal', function () {
$("#cartoonVideo").attr('src', url);
});
});
$('.activate_modal').click(函数(){
//get the id of the modal window stored in the name of the activating element
// var modal_id = $(this).attr('name');
//use the function to show it
//show_modal(modal_id);
alert("Hello! I am an alert box!!");
});
</script>
× Youtube 视频
要解决问题,请在 handleleftClick 中添加此内容
$(".modal-body").html('<iframe id="youtubeVideo" width="100%" height="350px" frameborder="0" scrolling="no" src=" ' + a + '?html5=1"; " allowtransparency="true" allowfullscreen ></iframe>');