使用Javascript更改网页的标题 [英] Changing the Title of a Web Page Using Javascript

查看:62
本文介绍了使用Javascript更改网页的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何动态更改网页标题?

我正在尝试使用JavaScript设置我的网页标题,因为我希望将存储在localStorage中的内容作为标题的一部分。我正在尝试的方法是使用document.createElement('title'),但是当我这样做时,我无法设置标题的文本。有没有办法以这种方式设置标题的文本,还是有不同的方式我应该这样做?

I am trying to set the title of my web page using JavaScript because I want something that is stored in localStorage to be part of the title. The approach that I am trying is to use document.createElement('title'), but I cannot set the text of the title when I do that. Is there a way to set the text of the title this way or is there a different way that I should be doing this?

推荐答案

使用

document.title = 'Your desired title';

这篇关于使用Javascript更改网页的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆