Hello, a few days ago I started to learn about electron and I started to make a small project to test the things around.
The idea is simple, after the main window opens there is an input field and a button, you enter something and then after you press the button it opens a link in a new window
Here is the code
index.js
const remote = require('electron').remote
const main = remote.require('./main.js')
window.onload = function() {
var myButton = document.getElementById('buttonPIP')
myButton.addEventListener('click', () => {
main.openWindow()
}, false)
}
main.js
const electron = require('electron')
const {BrowserWindow, app} = electron
let mainWindow = null;
app.on('ready', function() {
mainWindow = new BrowserWindow({width: 800, height: 800})
mainWindow.loadURL('file://' + __dirname + '/index.html')
mainWindow.on('closed', function() {
mainWindow = null
});
});
exports.openWindow = () => {
let win = new BrowserWindow({width: 400,
height: 300,
parent: mainWindow,
center: true,
alwaysOnTop: true,
title: "Player"
})
var link = 'http://player.twitch.tv/?volume=0.20&channel=' + document.getElementById('streamName').value
win.loadURL(link)
}
So my problem is that after I press the button a new blank opens with the right window title but it wont redirect to any page. I looked into devtool console and this is the error that shows up
Uncaught Error: Could not call remote function ''. Check that the function signature is correct. Underlying error: document is not defined
Error: Could not call remote function ''. Check that the function signature is correct. Underlying error: document is not defined
at callFunction (/home/crisfast/Desktop/Twitch PIP/node_modules/electron/dist/resources/electron.asar/browser/rpc-server.js:235:11)
at EventEmitter.<anonymous> (/home/crisfast/Desktop/Twitch PIP/node_modules/electron/dist/resources/electron.asar/browser/rpc-server.js:342:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents.<anonymous> (/home/crisfast/Desktop/Twitch PIP/node_modules/electron/dist/resources/electron.asar/browser/api/web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
I looked up for solutions but didn’t found something that would help me, also I mention that i use electron 1.4.15 and Ubuntu 16.04.
Thank you for your help!