I have a question about the new tab for the link.
Is there anyway I can set the browser tab title before user clicks a link? It seems like there is no way to debate the title for the new tab if the html contained in the new tab doesn't have title attribute. Am I right? How do I set the title?
//the href is dynamic so I can't set them one by one because I have 100+ html file here
<a href="test.html" target="_blank">open me<a>
The title that appears in your browser tab is called the page title. If you do not enter a page title, the title of your home page is displayed.
The title that appears in your browser tab is called the page title. If you do not enter a page title, the title of your home page is displayed. If you do not enter a title for your home page, then the site name is displayed. You can edit your browser tab page title at any time. Click Menus & Pages on the left side of the Editor.
For example, consider we want to add a text called Home to the browser tab when the user visits the home page of your website. So for that, we can use the title HTML element tag and put the text inside the opening and closing block of the title HTML tag. <!DOCTYPE html> <!--
Like almost any other browser, Chrome takes the title of a website and displays it as the tab name. Since most websites use meaning full titles for their pages, grabbing the title and setting it as the tab name is generally fine.
I have not seen addEventListener work reliably, especially when opening a new page using javascript. The best way to change the tab title and have it work reliably is to set a timeout until the page loads. You may have to play with the timeout value, but it works.
var newWindow = window.open(url, '_blank');
setTimeout(function () {
newWindow.document.title = "My Tab Name";
}, 100);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With