#The back button does not work
83 messages · Page 1 of 1 (latest)
No, there are no errors, it just stops functioning, I can record a video for a detailed study of this problem
share your code instead.
Ok
const { app, BrowserWindow, Menu, screen, ipcMain } = require('electron');
const path = require('path');
let win;
function createWindow() {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});
win.loadURL('https://ru.tradingview.com/chart/Irhk2lYq/');
const template = [{
label: 'Назад',
click: () => {
win.webContents.goBack();
}
},
{
label: 'Выход',
click: () => {
win.close();
}
}
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
win.on('close', (e) => {
e.preventDefault();
win.destroy();
});
ipcMain.on('close-window', () => {
win.close();
});
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
ipcMain.on('goBackHomeBoi', (event, arg) => {
win.webContents.goBack();
event.sender.send('WentBack', 'Done');
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
why do you think it doesnt work?
This is one of the files if you hint that the project is not complete, and since I tried different options, nothing comes to mind. I figured out the Exit button thanks to .destroy, and I don't understand what to do with this one
it doesn't answer the question
It turns out that when I start to expand one of the graphs and interact with the internal content of the site, the back button is automatically disabled in the console, there are no errors observed
in the console?
yes
no, I run the test in cmd (console) via npm start
I'm sorry, the main domain is completely different there, the personal account in which the links are, I'll fix it now and show you
??
This is the main page that the user gets to, in simple words, the Home page, where he can navigate through the rest of the charts, but when switching to the chart and interacting with it, it does not work to return to the main site rusbafet.ru , where all graphs are displayed
you should use website navigation
the charts they click on are on tradingview, how to use navigation if it's not a single site?
I tried to use it, but it still does not send this signal and the button does not work
Now I'll try again, assign the "Back" button instead of go.back is loadUrl
No, it didn't help
what doesnt work?
const template = [{
label: 'Назад',
click: () => {
win.loadURL('https://rusbafet.ru/');
}
errors?
no
why do you think it doesnt work then?
There are no errors, I click and it just doesn't work and that's it
add console.log into click handler
It gave out this ╨E╨░╨╢╨░╤In╨░ ╨║╨╜╨╛╨┐╨║╨░ "╨ E╨░╨╖╨░╨┤"
use english
english words in console.log
so its work
what electron version it is?
"electron": "^24.4.0"
does it work same withhttps://electronjs.org ?
I'll try it now
No, I do not observe such an error, since everything is static on https://electronjs.org in my example, the charts are dynamic and there is interaction with these elements on the Tradingview website
Build cross-platform desktop apps with JavaScript, HTML, and CSS
if problems because of charts it is not electron issue
you can try to .stop()
before loading new page
Please describe this method in more detail
I don't see any problem with the charts, they work and work, all this runs in Electron, so why doesn't the "Back" signal reach the main page. There was a similar problem with the "Exit" button, I solved it this way https://stackoverflow.com/questions/41937111/electron-close-button-not-working
The answer of the author James Shaji helped me in this case and now the "Exit" button works very well
Render and control web pages.
have you read this?
same way you can just do win.destroy()
without preventing close event
if site A work as expected and site B doesnt
problem with a site B
Yes, I used window.close() before, but it didn't work
without issue reproduction i cant tell you more
What is necessary for this? Should I provide the sources?
no
i need small part of your site that break default behavior
then put it into electron-fiddle
Here is the link to the graph https://ru.tradingview.com/chart/Irhk2lYq is that enough?
You tried to click on the graph and stretch it, authorization is needed, without authorization it worked for me too
yes
Try to reproduce the problem like this, after expanding the graph or other clicks on the page elements, as well as drawing any line leads to this
Which version have you tested through?
24.4.0
And if you try a newer or an older one, an error may be displayed?
in case that home doest work on site itself
i dont think its problem with version
something prevent page to unload
I don't know what it could be, I will test with other versions and look for the reason, maybe I will find something, thank you for your help, if you find the reason, please let me know
add ```
win.webContents.on("will-prevent-unload", (e) => {
e.preventDefault();
});