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

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

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

javascript 标签

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值