我想使用下面的广告代码,但我有问题后,静音视频关闭视频。当我关闭(另外它关闭20秒后自动)的广告,它播放的视频背景,仍然有声音。我如何静音视频后,我点击跳过广告按钮,当它自动关闭?我对jQuery或JavaScript一无所知。您能修改我的代码并发布解决方案吗?
<script>
window.setTimeout("document.getElementById('closead').style.display='none';", 6000);
</script>
<div class="advertisement" id="closead">
<a target="_blank" rel="nofollow" href="http://www.sitename.com">
<video id="dbx" style="object-fit: fill;" autoplay="" width="100%" height="100%">
<source src="https://www.w3schools.com/tags/mov_bbb.mp4" type="video/mp4">
</video>
</a>
<button onfocus="this.blur();" class="closecss" style="position:absolute;bottom: 2px;right: 0px;z-index: 999;background: #32b02b;color: #fff;padding: 13px;border-radius: 4px;font-weight: bold;cursor: pointer;border: 1px solid #2b9825;box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.15), 0 1px 0 0 #299023, 0 2px 3px 0 rgba(0, 0, 0, 0.25);" onclick="document.getElementById('closead').style.display='none';">SKIP AD</button>
</div>
<style>
.advertisement {
position: absolute;
z-index: 99;
height: 100%;
}
</style>
发布于 2018-05-25 07:57:31
试试今年吧
正如伊纳瓦尔的回答所说的那样
$(“#dbx”).prop(‘静音’,true);
$(Document).ready(function(){})中的行;
.advertisement {
position: absolute;
z-index: 99;
height: 100%;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
window.setTimeout("document.getElementById('closead').style.display='none';", 6000);
</script>
<div class="advertisement" id="closead">
<a target="_blank" rel="nofollow" href="http://www.sitename.com">
<video id="dbx" style="object-fit: fill;" autoplay="" width="100%" height="100%">
<source src="w3schools.com/tags/mov_bbb.mp4" type="video/mp4">
</video>
</a>
<button onfocus="this.blur();" class="closecss" style="position:absolute;bottom: 2px;right: 0px;z-index: 999;background: #32b02b;color: #fff;padding: 13px;border-radius: 4px;font-weight: bold;cursor: pointer;border: 1px solid #2b9825;box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.15), 0 1px 0 0 #299023, 0 2px 3px 0 rgba(0, 0, 0, 0.25);" onclick="document.getElementById('closead').style.display='none';MuteVideo()">SKIP AD</button>
</div>
<script>
function MuteVideo(){
$("#dbx").prop('muted', true);
}
</script>
发布于 2018-05-25 07:34:51
您可以使用静音属性静音视频。
jQuery("#dbx").prop('muted', true);发布于 2018-05-25 09:06:10
如果您可以修改上面的脚本,这是一个很好的方法。
<script>
function removeVIdeo(videoId){
var video = document.querySelector(videoId);
video.muted = true;
}
window.setTimeout(function(){
document.getElementById('closead').style.display='none';
removeVIdeo('#dbx');
},6000);
</script>
<div class="advertisement" id="closead">
<a target="_blank" rel="nofollow" href="http://www.sitename.com">
<video id="dbx" style="object-fit: fill;" autoplay="" width="100%" height="100%">
<source src="https://www.w3schools.com/tags/mov_bbb.mp4" type="video/mp4">
</video>
</a>
<button onfocus="this.blur();" class="closecss" style="position:absolute;bottom: 2px;right: 0px;z-index: 999;background: #32b02b;color: #fff;padding: 13px;border-radius: 4px;font-weight: bold;cursor: pointer;border: 1px solid #2b9825;box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.15), 0 1px 0 0 #299023, 0 2px 3px 0 rgba(0, 0, 0, 0.25);" onclick="removeVIdeo('#dbx');">SKIP AD</button>
</div>
<style>
.advertisement {
position: absolute;
z-index: 99;
height: 100%;
}
</style>
https://stackoverflow.com/questions/50523586
复制相似问题