gpt4 book ai didi

javascript - 使用上一个/下一个按钮扩展youtube视频的下拉菜单的 View 屏幕

转载 作者:行者123 更新时间:2023-12-03 06:16:15 26 4
gpt4 key购买 nike

请看看this link.

您会在这里找到一个下拉菜单,其中包含可以选择的YouTube视频列表。作为一项附加功能,每周的每一天都会显示另一个初始视频。

该脚本可以正常工作,并且可以很好地完成工作。您将在下面找到此脚本的代码。

<style>
.txt3 {
font-weight: normal;
font-size: 100%;
font-weight: bold;
font-family: Verdana;
}
.txt4 {
font-weight: normal;
font-size: 100%;
font-weight: bold;
font-family: Verdana;
margin-top: 2px;
margin-left: 0px;
color:#000000;
background: #F3FED0;
border: 2px solid #92AD34;
}
</style>

<script language=javascript>
var theSelect,theIframe;
var today = new Date(),

number_of_day = today.getDay();
$(document).ready(function() {
//var today = new Date();
//var n = today.getDay();
theSelect = document.getElementById('location');
theIframe = document.getElementById('myIframe');
theUrl = theSelect.options[number_of_day].value;
theIframe.src = theUrl;
});
function setIframeSource()
{
var theUrl;

if ( theSelect.selectedIndex > 0) {
theUrl = theSelect.options[theSelect.selectedIndex].value;
} else {
theUrl = theSelect.options[number_of_day].value;
}
theIframe.src = theUrl;
}
</script>
<form id="form1" method="post">
<label class="txt3"> De video-testimonial van:
<select class="txt4" id="location" onchange="setIframeSource()">
<option value="http://www.alumnei.nl/images/learninglane.jpg">... maak hier je keuze ...</option>
<option value="https://www.youtube.com/embed/tP4i7CiMHh4?rel=0">Monique van Neutegem</option>
<option value="https://www.youtube.com/embed/Bx5Np1wIXYs?rel=0">Marjon Heintjes</option>
<option value="https://www.youtube.com/embed/J-NChlqVAgY?rel=0">Els de Groot</option>
<option value="https://www.youtube.com/embed/r_UB0rTH7SA?rel=0">Arthur Alferink</option>
<option value="https://www.youtube.com/embed/t66K_g-fkFY?rel=0">Monique Fortuin</option>
<option value="https://www.youtube.com/embed/8DC-3DiVL4A?rel=0">Erna Slangen</option>
<option value="https://www.youtube.com/embed/8Gvu_lgZZAM?rel=0">Stephanie de Witte</option>
</select>
</label>
</form>
<br>

<iframe id="myIframe" src="http://www.alumnei.nl/images/learninglane.jpg" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="450" related="0" allowfullscreen scrolling="no"></iframe>

我的问题如下:

问题1:我想在视频窗口下方介绍上一个/下一个按钮。因此,如果用户要选择下一个视频,则不必每次都转到下拉菜单。如何才能做到这一点?

问题2:我如何引入一个额外的按钮(在视频窗口下方)以使下拉菜单中的所有视频彼此自动播放(因此从视频1到视频7不间断)?

最佳答案

幸运的是,我已经能够自己进行所需的修改。

请在下面找到实现此目的的相关脚本。

<style>
.txt3 {
font-weight: normal;
font-size: 100%;
font-weight: bold;
font-family: Verdana;
}
.txt4 {
font-weight: normal;
font-size: 100%;
font-weight: bold;
font-family: Verdana;
margin-top: 2px;
margin-left: 0px;
color:#000000;
background: #F3FED0;
border: 2px solid #92AD34;
}
.wrap {
text-align:center
}
#div1 {
display: inline-block;
border: 2px solid red;
float: left;
}
#div2 {
display: inline-block;
text-align: center;
border: 0px solid green;
}
#div3 {
display: inline-block;
border: 2px solid blue;
position: relative;
float: right;
}
select.center {
position: relative;
display: inline-block;
}
input.right {
position: relative;
float: right;
}
</style>

<script language=javascript>
function setIframeSource() {
//do whatever you're doing
;
}
function nextTiles(i) {
var e = document.getElementById("overlaySelector");
e.selectedIndex +=i ;
//loop-around from the top or bottom depending on increment/decrement
if(e.selectedIndex == -1) {
if(i>0) e.selectedIndex = 0;
else e.selectedIndex = e.length - 1;
}
setIframeSource(); //with the now updated selected option,
//do whatever you were doing when the user manually chooses something in the dropdown
}

var theSelect,theIframe;
var today = new Date(),

number_of_day = today.getDay();
$(document).ready(function() {
//var today = new Date();
//var n = today.getDay();
theSelect = document.getElementById('overlaySelector');
theIframe = document.getElementById('myIframe');
theUrl = theSelect.options[number_of_day].value;
theIframe.src = theUrl;
});

function setIframeSource() {
var theUrl;
if ( theSelect.selectedIndex > 0) {
theUrl = theSelect.options[theSelect.selectedIndex].value;
} else {
theUrl = theSelect.options[number_of_day].value;
}
theIframe.src = theUrl;
}
</script>

<iframe id="myIframe" src="http://www.alumnei.nl/images/learninglane.jpg" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="450" related="0" allowfullscreen scrolling="no"></iframe>

<div class="wrap">

<div id="div1"><input type="button" value="vorige" onClick="nextTiles(-1)"></div>

<div id="div2">
<form id="form1" method="post">
<label class="txt3"> De video-testimonial van:
<select class="txt4" id="overlaySelector" onchange="setIframeSource()">
<option value="http://www.alumnei.nl/images/learninglane.jpg">... maak hier je keuze ...</option>
<option value="https://www.youtube.com/embed/tP4i7CiMHh4?rel=0&fs=0&autoplay=1&modestbranding=1">Monique van Neutegem</option>
<option value="https://www.youtube.com/embed/Bx5Np1wIXYs?rel=0&fs=0&autoplay=1&modestbranding=1">Marjon Heintjes</option>
<option value="https://www.youtube.com/embed/J-NChlqVAgY?rel=0&fs=0&autoplay=1&modestbranding=1">Els de Groot</option>
<option value="https://www.youtube.com/embed/r_UB0rTH7SA?rel=0&fs=0&autoplay=1&modestbranding=1">Arthur Alferink</option>
<option value="https://www.youtube.com/embed/t66K_g-fkFY?rel=0&fs=0&autoplay=1&modestbranding=1">Monique Fortuin</option>
<option value="https://www.youtube.com/embed/8DC-3DiVL4A?rel=0&fs=0&autoplay=1&modestbranding=1">Erna Slangen</option>
<option value="https://www.youtube.com/embed/8Gvu_lgZZAM?rel=0&fs=0&autoplay=1&modestbranding=1">Stephanie de Witte</option>
</select>
</label>
</form>
</div>

<div id="div3"><input type="button" class="right" value="volgende" onClick="nextTiles(1)"></div>

</div>

欢迎任何进一步改进的建议;-)

关于javascript - 使用上一个/下一个按钮扩展youtube视频的下拉菜单的 View 屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43557707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com