electron-tabs
electron-tabs copied to clipboard
open link in a new tab
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
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.
it works with ipcRenderer communication thanks
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.
I'm using browserwindow and browserview, forgot to mention.