2

I have a webview tag, and I'm trying to execute javscript and read the result, as per the docs: Electron webview tag docs. However the callback is never executed:

@webviewOutlet.executeJavaScript("10+2", (n)-> console.log "#{n}") #Nothing in console

I'm using the WebView in NodeJS as part of an Atom package.

2 Answers 2

2

Here is missing required parameter userGesture and as a result, you passing function where expected boolean variable.

Try this:

@webviewOutlet.executeJavaScript("10+2", false, (n)-> console.log "#{n}") 
Sign up to request clarification or add additional context in comments.

Comments

0

The second parameter for the executeJavaScript function is not the callback, it is the userGesture.

The correct way to use this function is the following:

webview.executeJavaScript('10 + 2', false, (n) => { console.log(n) })

Of course, change the second parameter userGesture to your needs.

Documentation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.