I want to know the current URL of the browser-window. Is there any way to access window.location.href property of BrowserWindow or any other way to get it?
Asked
Active
Viewed 4,073 times
1 Answers
8
From the main process, use the window's webContents.getURL() method:
[...]
win = new BrowserWindow({ /* options */});
win.loadFile('index.html');
console.log (win.webContents.getURL();)

Cart Biya
- 96
- 1
-
This answer is acceptable. I've created this question to detect error URL( see this [question](https://stackoverflow.com/questions/56000178/win-reload-showing-showing-blank-white-window-in-electron) for more details). But `win.webContents.getURL()` showing the wrong URL to me – Freddy Daniel May 07 '19 at 04:26