Cannot use opener.someScriptVariable in Electron


Hello! I’m new on electron, thanks for providing it.

I implemented a web app and launched with electron.

I want to share some values with opener window and child window.

I tried like this,

//script in opener window

var apiServerInfo = 'http://api.url" ;
var runningChat = function (item) { ... }

//script in new window
('.drop-wrapper').dropzone({ url : opener.apiServerInfo + '/SSTalk/API/talk/', // just undefined in Electron, but web browsers having value. acceptedFiles : 'image/*', init : function(){ _self = this; this.on('sending', function(file, xhr, formData){ formData.append('photoImage', file); }) this.on('addedfile', function(file){ // alert('file added'); (’.drop-wrapper > .drop’).css(‘display’, ‘none’);
$(’#btn-send’).on(‘click’, function(e){
success : function(file, response){
if(response.result_code === ‘S0000’){
if(opener.runningChat !== ‘empty’){
opener.runningChat.sendImage(response.result.uploaded); // It also undefined in Electron

I get the varibles not undefined in Electron, how can I do for this?


To correct window.opener, and work facebook(and others) logins

You need use webPreferences.nativeWindowOpen=true, and set same webPreferences.affinity for mainWindow, and opened windows(hook on mainWindow.webContents.on('new-window'))