【问题标题】:How i get events in electron webcontents?我如何在电子网络内容中获取事件?
【发布时间】:2020-01-24 17:23:01
【问题描述】:

我正在使用电子应用程序。在 BrowserView 中使用网页内容。

我可以参加活动吗 this webcontents Events?

我只是这样尝试

view.Webcontents.on("Media-play",function(){
    console.log("blah-blah-");
})

但我无法得到。

我想处理像

这样的事件

我如何获得这些事件?

【问题讨论】:

  • 你是指自定义事件还是Dom事件?
  • 我的意思是 dom。

标签: javascript web electron


【解决方案1】:

网页内容:

Electron Web 内容的事件监听器:

const { BrowserWindow } = require('electron')

let win = new BrowserWindow({ width: 800, height: 1500 })
win.loadURL('http://github.com');

win.webContents.on('did-finish-load', () => {
   console.log('finished to load ');
})

可能的 WebContent 事件。参考:https://www.electronjs.org/docs/api/web-contents#instance-events

网络视图:

电子webviews的事件监听器。

HTML:

<webview id="webview" src="content.html"></webview>

Js:

let webview = document.getElementById("webview");
webview.addEventListener("dom-ready", () => {
     console.log("blah-blah-");
});

可能的 webview dom 事件。参考:https://www.electronjs.org/docs/api/webview-tag#dom-events

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 2012-08-04
    • 2012-05-29
    • 1970-01-01
    相关资源
    最近更新 更多