brrd / electron-tabs

Tab component for Electron
MIT License
697 stars 130 forks source link

about addTab title #188

Closed Nicky03 closed 1 year ago

Nicky03 commented 1 year ago

If addTab passes in an https address, can the title not be set, but automatically set to the title tag of the webpage?

brrd commented 1 year ago

You can do it this way (untested):

const tab = tabGroup.addTab({
  title: "Page is loading",
  src: "https://example.com"
});

tab.once("webview-dom-ready", (tab) => { 
  const title = tab.webview.getTitle() || "Untitled";
  tab.setTitle(title);
});