Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.external.invoke undefined #236

leaanthony opened this issue Feb 10, 2019 · 6 comments


Copy link

commented Feb 10, 2019

What OS are you using (uname -a, or Windows version)?

OSX 10.14.3 (18D42)

What programming language are you using (C/C++/Go/Rust)?

Apple LLVM version 10.0.0 (clang-1000.11.45.5)

What did you expect to see and what you saw instead?

window.external.invoke never appears when using Eval from main.


package main

import (

func main() {
	w := webview.New(webview.Settings{
		Width:  800,
		Height: 600,
		Title:  "Simple demo",
		Debug:  true,
		URL:    `data:text/html,<html><body><div id="app"></div></body></html>`,

	defer w.Exit()
	w.Dispatch(func() {
		w.Eval("var f = function() { if(window.external && window.external.invoke) { console.log('ready'); } else { console.log('waiting'); setTimeout(f, 10); } }; f();")


This code was written to try and work out why calling window.external.invoke kept failing. Looks like it never appears. The window opens and the console log counter goes up and up:

Also, and maybe I should open up a seperate issue, commenting out the URL line means Dispatch now doesn't work and that code is never called.


This comment has been minimized.

Copy link

commented Feb 13, 2019

I have the same problem, but I do not even get the debugging tools on OSX. I have set Debug to true. Any ideas?


This comment has been minimized.

Copy link

commented Feb 21, 2019

Nope. This is a total showstopper for me. The previous webview based code works fine.


This comment has been minimized.

Copy link

commented Apr 20, 2019

Same issue here, anyone found a workaround?


This comment has been minimized.

Copy link

commented May 13, 2019

I got around this by calling window.external.invoke after the DOM is ready.


document.addEventListener('DOMContentLoaded', () => {
  try {
  catch(e) {


w = webview.New(webview.Settings{
    Title:                  "MyWindow",
    URL:                    guiURL,
    Width:                  windowWidth,
    Height:                 windowHeight,
    ExternalInvokeCallback: handleExternalInvokeCallback,

func handleExternalInvokeCallback(w webview.WebView, data string) {
  switch data {
    case "DOMContentLoaded":
      w.Bind("windowController", windowController)

Can't say I like it, but it works...


This comment has been minimized.

Copy link

commented May 13, 2019

Thanks for this! I will try it.


This comment has been minimized.

Copy link

commented Jun 17, 2019

I had a problem after validating a form the solution was to use this

I called it like this window.webkit.messageHandlers.external.postMessage('');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants
You can’t perform that action at this time.