模态弹出窗口时暂停视频-HTML和Javascript

时间:2019-01-06 09:19:51

标签: javascript php jquery html forms

您好,我想在模式弹出窗口时暂停视频吗?这是代码

这是弹出窗口时的模式-我将其更改为jumbotron,因为我对此更加满意。

<div class="overlay">
  <br><br><br><br><br><br><br><br><br><br><br>

    <div class="text-center col-md-8" style="margin-left: 250px;">

         <div class="jumbotron">
          <h1><u>THIS IS AN ANNOUNCEMENT</u></h1>
          <h1>Please read the announcement</h1>
          <h3>You are a safe passenger</h3>
          <h1><?php echo $row['id']; ?> <?php echo $row['additional_info']; ?></h1>
          <p><a class="btn btn-primary btn-lg" href="#" role="button">TAPOS NA!</a></p>
        </div>

    </div>

这是视频src

<video oncontextmenu="return false;" src="../inflightapp/storage/app/public/movie_videos/<?php echo ''.$row2['movie_video'].''; ?>" id="noads" width="1px" controls controlsList="nodownload"> 

1 个答案:

答案 0 :(得分:0)

向视频添加id属性:

<video id="myVideo" ...

您可以使用JavaScript暂停视频。模式弹出时调用pauseVid();函数。

<script>
var vid = document.getElementById("myVideo");

function pauseVid() { 
  vid.pause(); 
} 
</script>