Answer the question
In order to leave comments, you need to log in
How to send a message to preload.js on button click?
Can't send message to preload.js
I didn't figure out how to do it via ipcMain or webContents. Please, help.
I need to send a message to preload.js by clicking on the "test send" button in order to work with it in the future.
The project itself is in the git https://github.com/AnotherAnkor/bowser-for-testers
I ask you not to beat my hands, because I'm not a developer, but I'm just playing around. But I'll be grateful for advice.
Answer the question
In order to leave comments, you need to log in
To handle the button in index.html added the following:
btnTS.addEventListener('click', function () {
// Listen for async message from renderer process
webview.send('ping', 'whoooooooh!')
console.log("sended");
});
ipcRenderer.on('ping', (event, message) => {
console.log(message);});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question