Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将本地文件加载到Electron应用程序的iframe中_Javascript_Html_Node.js_Electron - Fatal编程技术网

Javascript 将本地文件加载到Electron应用程序的iframe中

Javascript 将本地文件加载到Electron应用程序的iframe中,javascript,html,node.js,electron,Javascript,Html,Node.js,Electron,我正在构建一个应用程序,它可以让你预览本地存储在你机器上的HTML5横幅广告 到目前为止,我已经可以选择一个包含所有文件的目录 选择后,iframe的src将更新到该目录 ipcRenderer.on('selected-directory', (event, data) => { // update preview const previewer = document.getElementById('preview-section-iframe') previewer.

我正在构建一个应用程序,它可以让你预览本地存储在你机器上的HTML5横幅广告

到目前为止,我已经可以选择一个包含所有文件的目录

选择后,iframe的src将更新到该目录

ipcRenderer.on('selected-directory', (event, data) => {
   // update preview
   const previewer = document.getElementById('preview-section-iframe')
   previewer.src = data.filePaths + '\\html\\'
}
但是,不会加载横幅,html如下所示:

<iframe id="preview-section-iframe" title="Banner preview" width="300" height="600" src="G:\BANNERS\300x600\html\">   
</iframe>

但是,在开发工具中将鼠标悬停在src上时,src会显示:

file:///G:/_projects/_dev/_electron_apps/test/electron-快速启动/G:\BANNERS\300x600\html\


它似乎在应用程序文件中查找源代码。有没有办法阻止这种情况发生?

如果您的iframe需要一个文件路径,那么您就给了他一个文件夹的引用

试试这样的


非常感谢,马上!