是否可以打开一个新窗口并嵌入iframe?

amb*_*air 6 html javascript iframe popup window.open

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

window.open(URL,name,specs,replace)
Run Code Online (Sandbox Code Playgroud)

如何传递iframe代码而不是URL,以便iframe嵌入新窗口?请建议.

提前致谢.

Rob*_* M. 17

您没有传递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>')
Run Code Online (Sandbox Code Playgroud)