javascript 标签_使用JavaScript更改标签标题

待我称王封你为后i 2023-02-22 03:43 92阅读 0赞

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

  1. 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对象,否则将看不到任何效果。 您经常会看到setIntervaldocument.title一起使用,以快速更改标题以引起用户的注意。

翻译自: https://davidwalsh.name/change-title-javascript

javascript 标签

发表评论

表情:
评论列表 (有 0 条评论,92人围观)

还没有评论,来说两句吧...

相关阅读

    相关 JavaScript 标签语句

    JavaScript 标签语句 很多时候,难于理解一个概念,一个很关键因素是惑于它的名称。 尤其是在初学阶段,思路不开阔,且周边知识不够丰富的情况下更是如此。 标签语句...