WebView executeJavaScript doesn't work


I use electron to create a simple web browser. It’s strange that after I change the src property to load a new url and call executeJavaScript in event ‘did-stop-loading’, the javascript doesn’t execute.

webView.executeJavaScript(‘setTimeout(function(){alert(“test”)}, 2000);’);

Please help to give me some tips.


try put code in “did-finish-load” event