简体   繁体   English

电子窗口打开和记录关闭事件

[英]Electron Window Open and log Close Event

I'm using Electron for a Desktop Application. 我正在将Electron用于桌面应用程序。 I'd liked to open a different Window by a button on main window (index.html). 我想通过主窗口(index.html)上的按钮打开另一个窗口。

Therefore, I found BrowserWindow from the Electron API. 因此,我从Electron API中找到了BrowserWindow But I'm totally new in Electron, and I try to get to know the whole Framework. 但是我对Electron完全陌生,我试图了解整个框架。

I have a "a"-link Tag on main window, which is my button. 我在主窗口上有一个“ a”链接标签,这是我的按钮。 This should open a new defined Electron Window. 这将打开一个新定义的电子窗口。 Maybe by an onclick event? 也许是通过onclick事件?

If the new opened window is closed, on main window a defined Javascript Event like (reload();) should triggered. 如果关闭了新打开的窗口,则应在主窗口上触发已定义的Javascript事件,例如(reload();)。

So my question is. 所以我的问题是。 How is the best way to open a Window and how can i "log" in main window, when the new window is closed an fire my JS-Event. 打开窗口的最佳方法是什么,当新窗口关闭时,如何在主窗口中“登录”我的JS-Event。

Thanks 谢谢

This might help you. 这可能对您有帮助。 It'll execute javascript on your Main Window when the New Window is closed. 关闭新窗口后,它将在您的主窗口上执行javascript。

newWindow.on('closed', function(e){
        mainWindow.webContents.executeJavaScript(`alert("test");`);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM