Webview is not capturing mouse events like click


Hi, I’m using Electron 1.4.8 on Windows 10. Mouse events in WebView don’t work.
I’m trying to register click event using jQuery:

webview.on('click', function() {
    console.log("do something")


webview.click(function() {
    console.log("do something")

I tried also standard events:

webview.addEventListener('click', function() {
    console.log("do something")

and it doesn’t work.


I don’t believe you can add an event listener on the webview itself but what you can do is add that event on the webview’s body element.


Ok but when I use $(document).click() event, this event is not working on webview. Is there a workaround for this?


The problem is that $(document).click() is a event called on the parent view and in this case on the webview container.
Have you tried $('body').click() inside your webview’s script? Not the paarent script.
Please, append some code sample so I can see exactly what you are trying to do and eventually provide a better answer.


Ok thank you :). Problem has been solved


Glad I could help :slight_smile:


Hey @Sential How did you solve this? I am using latest electron app and I am trying to get click event happening inside a webview. Any help would be appreciated. Thanks!