- I tried to use window.open('url', '_blank') with setTimeout() and window.onload() to set the new tab title, but it is not wordked very well, and the new tab will be blocked by some user's browser. So, i tried another way that clicking the 'a' tag to open my new tab, but i can not set the tab title now.
- Then i tried the way that add a 'iframe' tag , it seemed useful , but it also need using window.open() that maybe blocked by user's brower.
- I want to name the new tab title with a 'file name' because of the new tab will load the file stream.
// create the url for blob
// let pdfUrl = URL.createObjectURL(blob);
// preview the file with new tab
// let newTabTitle = gDocName + " - " + gDocSubPath;
// let win = window.open(pdfUrl, '_blank');
// win.document.title = newTabTitle;
let link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.click();
window.URL.revokeObjectURL(link.href);
link.remove();
To find a stable and effective solution to set the new tab title...