Disable all external links #716

Closed
opened 2026-01-29 16:46:38 +00:00 by claunia · 5 comments
Owner

Originally created by @serdar-sahin on GitHub (Oct 26, 2021).

Originally assigned to: @GregorBiswanger on GitHub.

Hi, firstly thank you for your great job.

How can i disable all external links in window?
For example, let's open a youtube video page, but clicking on other links on the page does not open a new window.

Originally created by @serdar-sahin on GitHub (Oct 26, 2021). Originally assigned to: @GregorBiswanger on GitHub. Hi, firstly thank you for your great job. How can i disable all external links in window? For example, let's open a youtube video page, but clicking on other links on the page does not open a new window.
claunia added the question label 2026-01-29 16:46:38 +00:00
Author
Owner

@danatcofo commented on GitHub (Dec 6, 2021):

I use this snippet inside my windows

document.addEventListener('DOMContentLoaded', () => {
    document.addEventListener('click', (e) => {
      if (e.target.href && e.target.host != window.location.host) {
        e.preventDefault();
        e.stopPropagation();
        // do something else...
        return false;
      }
    }, true);
  });
@danatcofo commented on GitHub (Dec 6, 2021): I use this snippet inside my windows ```javascript document.addEventListener('DOMContentLoaded', () => { document.addEventListener('click', (e) => { if (e.target.href && e.target.host != window.location.host) { e.preventDefault(); e.stopPropagation(); // do something else... return false; } }, true); }); ```
Author
Owner

@serdar-sahin commented on GitHub (Dec 8, 2021):

@danatcofo Thanks for your answer, but I need to change my question.
I open a new window with youtube embed url.
There are different links of youtube on the video screen that opens.
Clicking on these links opens other windows.
I want to block these windows.

@serdar-sahin commented on GitHub (Dec 8, 2021): @danatcofo Thanks for your answer, but I need to change my question. I open a new window with youtube embed url. There are different links of youtube on the video screen that opens. Clicking on these links opens other windows. I want to block these windows.
Author
Owner

@danatcofo commented on GitHub (Dec 8, 2021):

It's probably similar concept. Google it for a web page. It would be the same method in electron. Remember electron is just web pages with some raisins added.

@danatcofo commented on GitHub (Dec 8, 2021): It's probably similar concept. Google it for a web page. It would be the same method in electron. Remember electron is just web pages with some raisins added.
Author
Owner

@serdar-sahin commented on GitHub (Dec 10, 2021):

I guess an interception is not allowed inside the iframe.

@serdar-sahin commented on GitHub (Dec 10, 2021): I guess an interception is not allowed inside the iframe.
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

@GregorBiswanger commented on GitHub (Mar 28, 2023): 🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉 With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#716