I am using electron with angular 5. Trying to open each router link as a new tab but I am not finding anything that could help me to achieve this. Is it possible to achieve?
If you don’t like using the keyboard, mouse, or trackpad in unusual ways to open links in new tabs, or if you’re physically disadvantaged, then browser extensions can help. Some browsers also come with the option to open links in new tabs as opposed to new windows.
However there is one catch, if you add mentioned handler to mainWindow instead of mainWindow.webContents you will end up with opening new Electron window instead of a new tab in the default system browser.
to open a Vue Router link in a new tab, we can call the $router.resolve method to get the full URL from the route name, path, parameter and query values. to call this.$router.resolve with the with an object with the route name and the query parameters to return an object that has the href property with the URL resolved from the values.
This is a bit oversimplified. First of all you may not have an access to the electron package from your frontend code (e.g. in case of externally loaded React application). What is more with that solution you would have to rewrite all the links to use onClick event instead of a very convenient href attribute.
Have you tried adding target="_blank" to you tag? You could also try a click navigation function as well.
<a routerlink="someUrl" target="_blank">
or
<a routerlink="someUrl" (onClick)="navigate(someUrl)">
public navigate(url: string):void {
window.open(url);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With