Webview stealing click, touchstart, touchend events


#1

I’m working on creating an Electron application that loads an external URL in a webview tag. The code is fairly simple, basically a div container that holds the webview.
<div id="container"> <div id="content"><webview src="..." /></div> </div>

There is a script that runs on this page and within this script I’m trying to add a function where clicking in a specified location on the screen will reload the webview (proof of concept, final design would be more complex) using webview.reload(). However, adding .on(‘click’) to document, ‘webview’, ‘body’ won’t fire the click event. I made the contents of the webview a blank html page and click still won’t fire. Mousedown and mouseup will both fire, but they don’t work with touchscreens. Click, touchstart, and touchend all don’t fire. This app is being designed for touchscreens so mousedown and mouseup aren’t viable options.

Within my code I currently have:
$(document).on('click', function(e) { console.log('click');});
which does nothing, but if I replace ‘click’ with ‘mousedown’ it works. Click does work if I click anywhere off the webview, but since the webview is intended to be loaded to fill the entire screen I can’t rely on that.

Also of note is that I don’t want the background process to steal the clicks either - there are elements within the webview that need to be clicked in the final product, but that is currently functioning as it should when loading a non-blank page.

Any help would be appreciated!


#3

Previous post was incorrect. I made a very basic application in electron. There are a few files. First is main.js, creates a window (exact code from electron getting started section). Then there’s index.html, basically adds an event listener to document listening for a click that logs the click, mousedown, and mouseup in console. Structure is a div containing a webview pointing to yet another file I made, blank.html. This file is just a body saying hello world. I’d add the code but I’m not familiar with formatting so it always ends up left aligned.
When clicking anywhere in the window that isn’t over the webview it logs “mousedown mouseup click” but when clicking on the webview it only logs "mousedown mouseup"
There are no other files or event listeners anywhere that would “steal” the event from the renderer process.