javascript 标签
Changing the tab (or window) title is an age old practice. Gmail does it to notify the user of a new chat message and this blog does it to update the tab title after a new page loads via AJAX. How is it done? By setting a property on the document object, of course:
更改选项卡(或窗口)标题是一种古老的做法。 Gmail会通过它通知用户新的聊天消息,而该博客是通过AJAX加载新页面后更新标签标题。 怎么做? 通过在document对象上设置属性,当然:
That property, of course, is document.title:
该属性当然是document.title :
document.title = 'Hello!'; // New title :)One common misconception is that you change the window.title property, but you must use the document object, otherwise you'll see no effect. You'll oftentimes see a setInterval used with document.title to quickly change title to get the user's attention.
一种常见的误解是更改window.title属性,但必须使用document对象,否则将看不到任何效果。 您经常会看到setInterval与document.title一起使用,以快速更改标题以引起用户的注意。
翻译自: https://davidwalsh.name/change-title-javascript
javascript 标签