如何在 svelte 文件中加载页面时创建自动弹出视频?

How to create an automatic popup video when a page loads in a svelte file?

我正在构建一个作品集,并计划在用户打开网站时在其中播放视频。如何添加 iframe 以在页面加载时自动打开?我正在使用 sveltekit 在网站上创建页面。

我会试试

document.onload = {
  let iframe = "<iframe> ... </iframe>";
  let frameWrap = document.querySelector('.frame-wrapper');
  frameWrap.innerHTML = iframe
  // or: frameWrap.insertAdjacentHTML('beforeend', iframe)
}

您可以使用 bootstrap 模式 window 来显示它 https://getbootstrap.com/docs/4.0/components/modal/

例如

 <script>$(document).ready (function(){
        $('#myModal').modal('show');
    
    
    });
    </script>
    
    <div class="modal fade bd-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
    
    
    
    </div>
    <div class="modal-body">
    
     <video width="400">
  <source src="#" type="video/mp4">

    </div></video>
    
    <br>
    <input type="checkbox" id="cb1" />
    <label2 for="cb1" data-dismiss="modal">Close</label2>
    
    
    
    
    </div>
    </div>
    </div>