I'm new to Electron, and I'm trying to do a function from a click on a menu. Here is my example.
index.html
<!DOCTYPE html>
<html lang="pt-br" dir="ltr">
<head>
<meta charset="utf-8">
<title>Electron</title>
<script src="main.js"></script>
</head>
<body>
<input type="text" name="campo" id="campo" value="">
<button type="button" name="funcao" onclick="funcao()">Função</button> <br /><br />
<input type="text" name="url" id="url">
</body>
</html>
In this example, typing something into the "url" input and clicking the button will show what was typed in the "campo" input. What I wanted to do is do the same but by clicking on the "funcao" menu.
main.js
(part of the menu with the function below)
{
label: 'Função',
click () { funcao(); }
},
function funcao() {
document.getElementById("campo").value = document.getElementById("url").value;
}
The error is this:
"ReferenceError: document is not defined"
Edit: My english is bad, I used Google Translate, sorry.