Get Url of window #127

Closed
opened 2026-01-29 16:31:50 +00:00 by claunia · 1 comment
Owner

Originally created by @ru-sh on GitHub (Feb 20, 2018).

Originally assigned to: @GregorBiswanger on GitHub.

Is it possible to get the url of a window?
I'm trying to detect if browser was redirected and find out where it was redirected.

Originally created by @ru-sh on GitHub (Feb 20, 2018). Originally assigned to: @GregorBiswanger on GitHub. Is it possible to get the url of a window? I'm trying to detect if browser was redirected and find out where it was redirected.
claunia added the question label 2026-01-29 16:31:50 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Feb 20, 2018):

Hey @ru-sh,

use from the chrome dev tool the console and type:
window.location.href

Another way is to send you the information over the IPC... As example:

Your HTML-View:
<script> var { ipcRenderer } = require("electron"); ipcRenderer.send("currentUrl", window.location.href); </script>

Your C# Part:
public IActionResult Index() { Electron.IpcMain.On("currentUrl", (url) => { // Here you get the url from url parameter }); return View(); }

I hope my answer helps you.

@GregorBiswanger commented on GitHub (Feb 20, 2018): Hey @ru-sh, use from the chrome dev tool the console and type: `window.location.href` Another way is to send you the information over the IPC... As example: **Your HTML-View:** `<script> var { ipcRenderer } = require("electron"); ipcRenderer.send("currentUrl", window.location.href); </script> ` **Your C# Part:** ` public IActionResult Index() { Electron.IpcMain.On("currentUrl", (url) => { // Here you get the url from url parameter }); return View(); } ` I hope my answer helps you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#127