Javascript Electron应用程序显示未定义的document.body
您好,我正在使用electron加载外部URL,在外部URL中,我有下面的脚本显示iframe inside window.openJavascript Electron应用程序显示未定义的document.body,javascript,electron,Javascript,Electron,您好,我正在使用electron加载外部URL,在外部URL中,我有下面的脚本显示iframe inside window.open var myWindow = window.open("", "_blank", "width=600,height=400"); myWindow.document.body.innerHTML = "<iframe allowFullScreen='true'></iframe>"; var myWindow=window.open(
var myWindow = window.open("", "_blank", "width=600,height=400");
myWindow.document.body.innerHTML = "<iframe allowFullScreen='true'></iframe>";
var myWindow=window.open(“,”_blank“,”宽度=600,高度=400”);
myWindow.document.body.innerHTML=“”;
在普通浏览器中工作正常,但在electron应用程序中,我收到以下错误:
未捕获类型错误:无法读取未定义的属性“body”
欢迎提出任何建议 根据Electron文档,
window.open
返回一个对象:
类别:BrowserWindowProxy
进程:渲染器
浏览器窗口代理
对象从窗口返回。打开
并
为子窗口提供有限的功能
而不是:
myWindow.document.body.innerHTML = "<iframe allowFullScreen='true'></iframe>";
myWindow.document.body.innerHTML=“”;
你可以尝试:
myWindow.eval (`document.body.innerHTML = "<iframe allowFullScreen='true'></iframe>";`);
myWindow.eval(`document.body.innerHTML=“”;`);
请注意,这里使用了反勾号字符串符号,以避免转义单引号和双引号,但这肯定是一个品味问题
嗯