Electron.NET
Electron.NET copied to clipboard
Disable all external links
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.
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 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.
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.
I guess an interception is not allowed inside the iframe.
🎉🚀 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!