javascript怎么修改浏览器title
时间:2022-02-11 16:02
javascript修改title的方法:1、使用“document.getElementsByTagName("title")[0].innerText='值';”语句来修改。2、使用“document.title='值';”语句来修改。 本教程操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。 title在html中属于特殊的节点元素,使用javascript修改title?下面本篇文章给大家介绍一下修改方法。 方法1:innerText 方式 方法2:document.title方式 经过测试,还可通过document.title 设置title的值。 例子 我们在浏览器取得了焦点和失去焦点的时候改变title的值,可以发现切换浏览器选项卡的时候,title发生了改变。 更多编程相关知识,请访问:编程视频!! 以上就是javascript怎么修改浏览器title的详细内容,更多请关注gxlsystem.com其它相关文章!document.getElementsByTagName("title")[0].innerText = '需要设置的值';
console.log(document.title); # 可以获取title的值。
document.title = '需要设置的值'; # 设置title的值。
window.onfocus = function () {
document.title = '恢复正常了...';
};
window.onblur = function () {
document.title = '快回来~页面崩溃了';
};