- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于要在Webview中加载远程内容,因此我添加了 contextIsolation
。
使用预加载脚本内部的webFrame.executeJavascript(...)
,如何将无法序列化的对象传递到内部网页的上下文中?
更具体地说,这是我的示例:
preload.js:
// In the preload.js context
const { ipcRenderer, webFrame } = require('electron')
const ipc = {
send (data) {
ipcRenderer.sendToHost(...)
}
}
// Now I want to pass down ipc to the webpage's context
// This webpage is expecting window.myApp.ipc, so that it could use it like window.myApp.ipc.send(...)
webFrame.executeJavaScript(`window.myApp.ipc = ${ipc}`); // Doesn't work.
最佳答案
无法通过executejavascript发送不可序列化的对象。如果您的预加载脚本是用于Webview的,则可以将某些对象附加到window
中以进行全局访问。
关于electron - Webframe executeJavascript传递对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50629008/
在最近的一个 Electron 项目中开始对我的 js 文件进行排序时,我停止了 webview.executeJavascript webview是一个变量,它是我的 webview 上的 quer
我需要将 NPM 包注入(inject) BrowserView通过使用 executeJavaScript .包裹是Web3这是我迄今为止尝试过的。 import Web3 from 'web3'
当我尝试 browser.ExecuteJavascript("alert('ExecuteJavaScript works!');") 它工作正常(在创建浏览器时弹出警告) .当我尝试 browse
我的网络应用程序使用 ipcRender.send 向监听 Electron ipcMain.on 询问来自系统的值。该过程是异步的,因此一旦 Electron 从系统中获取值,它就会发起对应用程序的
我正在构建一个不能使用webview的应用程序,因为它无法完成我想做的所有事情,而使用mainWindow则可以。 但是,我需要使用整个javascript文件,而不仅仅是文本。 示例: const
大家好,在我的项目中,我有三个 js 文件,main.js、browser.js 和 inject.js,在 browser.js 我已经实现了所有与我的 webview 相关的点击操作和许多功能
我是一名优秀的程序员,十分优秀!