index.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. overflow: hidden;
  17. }
  18. .videoBox {
  19. width: 100%;
  20. height: 100%;
  21. background-color: black;
  22. position: relative;
  23. }
  24. .videoBox video {
  25. position: absolute;
  26. top: 50%;
  27. left: 50%;
  28. transform: translate(-50%, -50%);
  29. max-width: 100%;
  30. max-height: 100%;
  31. }
  32. .skipTxt {
  33. position: absolute;
  34. z-index: 10;
  35. right: 15px;
  36. top: 15px;
  37. width: 60px;
  38. height: 30px;
  39. background-color: rgba(0, 0, 0, .6);
  40. line-height: 30px;
  41. text-align: center;
  42. color: #fff;
  43. text-decoration: none;
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <!-- 开场视频 -->
  49. <div class="videoBox">
  50. <video src="./myCode/video.mp4" controls muted></video>
  51. <a class="skipTxt" href="./model.html">跳 过</a>
  52. </div>
  53. </body>
  54. <script>
  55. const videoBox = document.querySelector('.videoBox')
  56. const videoDom = document.querySelector('.videoBox video')
  57. const videoBtnDom = document.querySelector('.skipTxt')
  58. // 自动播放视频
  59. videoDom.play()
  60. // 点击按钮,或者视频播放完毕的回调
  61. const videoPalyEnd = () => {
  62. videoBtnDom.click()
  63. // const topUrl = window.location.href
  64. // console.log('-------视频播放完毕,或者点击跳过--------', topUrl);
  65. // const a = document.createElement('a');
  66. // a.setAttribute('href', topUrl.replace('index', 'model'));
  67. // // a.setAttribute('target','_blank');
  68. // a.style.display = 'none'
  69. // document.body.appendChild(a);
  70. // a.click();
  71. }
  72. videoDom.addEventListener('ended', function () {
  73. videoPalyEnd()
  74. }, false)
  75. </script>
  76. </html>