Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open each router link as a new tab in an Electron app

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?

like image 337
Dhaanappagouda Patil Avatar asked Apr 27 '18 03:04

Dhaanappagouda Patil


People also ask

How to open links in New tabs?

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.

Is it possible to open electron window instead of new tab?

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.

How to open a vue router link in a new tab?

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.

Why can’t I use electron in onClick event?

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.


1 Answers

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);
    }
like image 185
Nolan Walker Avatar answered Oct 23 '22 15:10

Nolan Walker