executeJavascript is not a function


#1

I am trying to call executeJavascript method when the webview is ready. I tried the following code below:

function init() {
      webview = document.querySelector('webview');
      webview.addEventListener('dom-ready', () => {
      webview.executeJavascript('alert("hello!");');
      })
}

In the console, I’ll get an error message of webview.executeJavascript is not a function. I’ve tried insertCSS method and that works fine but executeJavascript method doesn’t exist even though it’s in the documentation. Any ideas?

I am using Electron 1.7.9 running on MacOS.


#2

according to https://electronjs.org/docs/api/webview-tag#webviewexecutejavascriptcode-usergesture-callback

it is executeJavaScript


#3

Thanks! somehow I had overlooked that.