Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the outcome of setting node-integration to false when creating a new browser window in Electron?

Tags:

electron

In order to get jQuery to load and function correctly in a HTML page I was opening in Electron (formerly Atom Shell), I had to disable Node integration when creating the BrowserWindow in my main.js file.

Can someone please tell me what setting node-integration: false will keep me from being able to do that I would normally be able to do had I not disabled it?

like image 815
Bryan Avatar asked Apr 25 '15 02:04

Bryan


People also ask

What is node integration in Electron?

Electron node integration refers to the ability of accessing Node. js resources from within the “renderer” thread (the UI). It is enabled by default in Quasar CLI, although Electron is encouraging developers to turn it off as a security precaution.

How can an Electron open another window?

Windows can be created from the renderer in two ways: clicking on links or submitting forms adorned with target=_blank. JavaScript calling window. open()

How do you find the mainWindow Electron?

To safely get the mainWindow in electron, I store its ID in a env variable and call BrowserWindow. fromId(ID) when needed. BrowserWindow. getFocusedWindow() will not work in some case, for exemple if you load an URL from a child window to the main window.


1 Answers

Setting node-integration to false will disable node.js in the renderer process - i.e. your app can only do what a web browser will do. Instead of doing this, use Zepto.js which is compatible with Electron and has the same API.

like image 153
Ana Betts Avatar answered Sep 24 '22 16:09

Ana Betts