首页 > 解决方案 > 嵌入 youtube 导致 js 警报功能失败

问题描述

我在我的网站中嵌入了 Youtube 视频;但是,它导致第一个警报功能失败。

在我单击确认按钮之前,警报对话框将弹出然后立即消失。

这是代码:

<iframe width="560" height="315" src="https://www.youtube.com/embed/bhxhNIQBKJI" 
   frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<script>alert("1");</script>
<script>alert("2");</script>

如果我添加第二个警报脚本,第一个失败,但第二个运行良好。我怎么解决这个问题?

标签: javascriptyoutubealert

解决方案


推荐阅读