Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open link in a new tab #1

Open
Devhercule opened this issue Jul 31, 2017 · 4 comments
Open

open link in a new tab #1

Devhercule opened this issue Jul 31, 2017 · 4 comments
Labels

Comments

@Devhercule
Copy link

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

@Vj3k0 Vj3k0 added the question label Aug 5, 2017
@Vj3k0
Copy link
Owner

Vj3k0 commented Aug 5, 2017

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.

@Devhercule
Copy link
Author

it works with ipcRenderer communication
thanks

@PieterRomeyns
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants