Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute script using BrowserWindow object in Electron?

I have a BrowserWindow object that pointing to a website.

mainWindow.loadUrl('http://example.com/');

Now I want to execute scripts on this website, so I'm looking for a method like window.eval in node-webkit, but I have not found. Anyone know?

Thanks in advance!

like image 408
Tuan Ha Avatar asked Dec 25 '22 12:12

Tuan Ha


1 Answers

webContents.executeJavaScript is the method:

myCoolWindow.webContents.executeJavaScript('window.close()');
like image 184
Ana Betts Avatar answered Dec 28 '22 11:12

Ana Betts