index.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE html>
  2. <html lang="ch-zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>常中e大观园</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. width: 100vw;
  15. height: 100vh;
  16. max-width: 500px;
  17. margin: 0 auto;
  18. overflow: hidden;
  19. }
  20. .videoBox {
  21. width: 100%;
  22. height: 100%;
  23. background-color: black;
  24. position: relative;
  25. }
  26. .videoBox video {
  27. position: absolute;
  28. top: 50%;
  29. left: 50%;
  30. transform: translate(-50%, -50%);
  31. max-width: 100%;
  32. max-height: 100%;
  33. }
  34. .skipTxt {
  35. position: absolute;
  36. z-index: 10;
  37. right: 15px;
  38. top: 15px;
  39. width: 60px;
  40. height: 30px;
  41. background-color: rgba(0, 0, 0, .6);
  42. line-height: 30px;
  43. text-align: center;
  44. color: #fff;
  45. text-decoration: none;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <!-- 开场视频 -->
  51. <div class="videoBox">
  52. <video src="./myCode/video.mp4" controls muted></video>
  53. <a class="skipTxt" href="./model.html">跳 过</a>
  54. </div>
  55. </body>
  56. <script>
  57. const videoBox = document.querySelector('.videoBox')
  58. const videoDom = document.querySelector('.videoBox video')
  59. const videoBtnDom = document.querySelector('.skipTxt')
  60. // 自动播放视频
  61. videoDom.play()
  62. // 点击按钮,或者视频播放完毕的回调
  63. const videoPalyEnd = () => {
  64. videoBtnDom.click()
  65. // const topUrl = window.location.href
  66. // console.log('-------视频播放完毕,或者点击跳过--------', topUrl);
  67. // const a = document.createElement('a');
  68. // a.setAttribute('href', topUrl.replace('index', 'model'));
  69. // // a.setAttribute('target','_blank');
  70. // a.style.display = 'none'
  71. // document.body.appendChild(a);
  72. // a.click();
  73. }
  74. videoDom.addEventListener('ended', function () {
  75. videoPalyEnd()
  76. }, false)
  77. </script>
  78. </html>