electron-tabs icon indicating copy to clipboard operation
electron-tabs copied to clipboard

open link in a new tab

Open Minyar2004 opened this issue 7 years ago • 4 comments

Hi,

I'm using your module electron-tabs to handle tabs il my Electron application.

I want to know how is it possible to open a new tab from an existing one. I want that the links existing in my webview can be opened in a new tab.

I added this coded in my referer.js :

const Menu = require('electron').remote.Menu;

document.querySelector('.etabs-views').addEventListener('contextmenu', (event) => {
	event.preventDefault();
	const template = [
		{
			label: 'open in a new tab,
			click: () => {
				let tab = tabGroup.addTab(function(){
					let tab = {
						title: 'new tab',
						src: 'http://www.example.com',
						visible: true,
						closable: true,
						active: true,
						ready: tab => {
							let webview = tab.webview;
						}
					};
					tabId++;
					return tab;
				});
			}
		}
	];
	const menu = remote.Menu.buildFromTemplate(template);
	menu.popup();
});

With this code, i can display the context menu when i click right, but I want to :

1/ display this menu only on clickable link

2/ open link in a new tab

Is it possible with your module?

Thank you

Minyar2004 avatar Jul 31 '17 15:07 Minyar2004

You can communication via ipcRenderer to manually implement this on your code. Just fire some action, listen to it and then open new tab. I don't think there is some automatic way to do this.

Vj3k0 avatar Aug 05 '17 06:08 Vj3k0

it works with ipcRenderer communication thanks

Minyar2004 avatar Sep 25 '17 08:09 Minyar2004

Hi, would you happen to have an example for this? I'm trying to do the same thing, but can't figure it out. i have a html file named dashboard, wich contains some links. dashboard.html is loaded in a tab when starting the app. I want to open a new tab from a dashboard.html link.

PieterRomeyns avatar Jun 10 '19 19:06 PieterRomeyns

I'm using browserwindow and browserview, forgot to mention.

PieterRomeyns avatar Jun 10 '19 19:06 PieterRomeyns