mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Prevent opening new windows #768
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @delasource on GitHub (Mar 3, 2022).
There is electrons "new-window" event. But i can not call
event.preventDefault()in C# code (eventbrowserWindow.OnNewWindowForTab). How am i be able to prevent opening new windows of my application? (for example when the user middle-mouse-clicks a link)However, it is marked deprecated in the documentation in favor of this function on the webContents class. So how can i access that? There are plenty of methods that are not implemented in Electron.Net.
Related to #434
@danatcofo commented on GitHub (Mar 3, 2022):
you have to do that in the javascript on the page itself. You can't do everything in .net.
Here is the code I use to prevent navigating away. For other similar scenarios I would suggest doing a google search. You have somewhat more freedom in the electron world than a standard browser.