gpt4 book ai didi

javascript - 是否可以打开一个新窗口并将 iframe 嵌入其中?

转载 作者:太空狗 更新时间:2023-10-29 14:42:36 29 4
gpt4 key购买 nike

我需要打开一个新窗口,我想在 iframe 中嵌入一个视频并在这个窗口中显示它。正常的弹出窗口语法是:

window.open(URL,name,specs,replace)

如何传递 iframe 代码而不是 URL,以便将 iframe 嵌入到新窗口中?请提出建议。

提前致谢。

最佳答案

您无需将 iframe 代码传递给 window.open,而是获取正在打开的窗口的句柄并将 iframe 写入该窗口。

var win = window.open();
win.document.write('<iframe width="560" height="315" src="//www.youtube.com/embed/mTWfqi3-3qU" frameborder="0" allowfullscreen></iframe>')

关于javascript - 是否可以打开一个新窗口并将 iframe 嵌入其中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20235772/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com