问题描述
我正在尝试使用 Twitter 编写一个包装器.io/" rel="noreferrer">Electron(以前的 Atom Shell).
I'm trying to write a wrapper for Twitter using Electron (formerly Atom Shell).
我的 main.js
文件(它看起来几乎与Hello World"的例子,我只是在一个地方改了):
My main.js
file (it looks almost identical to the "Hello World" example, I just changed it in one place):
我尝试在 mainWindow.loadUrl()
之后立即调用 alert()
函数,但它没有执行.
I try to call alert()
function right after mainWindow.loadUrl()
but it does not execute.
我知道 main.js
文件就像我的应用程序的服务器端,但问题是……如何在页面上调用 JavaScript 函数?我应该在哪里写代码?
I understand that main.js
file is like the server side of my app, but the question is... How can I call a JavaScript function on page? Where should I write the code?
例如,我想执行此操作:
For example, I want to perform this:
推荐答案
我已经解决了这个问题.下面是示例代码:
I have solved the problem. Here's the example code:
这篇关于如何在 Electron 渲染的网页上调用 JavaScript 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!