WebView executeJavaScript doesn't work


#1

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);’);
webView.executeJavaScript('alert(“test”);‘);

Please help to give me some tips.


#2

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