HTMLTitleElement
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLTitleElement
接口由文档的 <title>
实现。此元素继承 HTMLElement
接口的所有属性和方法。
实例属性
从其父接口 HTMLElement
继承属性。
HTMLTitleElement.text
-
表示文档标题文本的字符串。
实例方法
无特定方法;从其父接口 HTMLElement
继承方法。
示例
请勿混淆 document.title
和 document.querySelector('title')
。
前者只是一个 setter/getter 方法,用于设置或读取文档标题的内部文本值,后者是 HTMLTitleElement
对象。因此你不能写:document.title.text = "Hello world!";
。
相反,你可以简单地写:document.title = "Hello world!";
,这相当于 document.querySelector('title').text = "Hello world!";
。
规范
Specification |
---|
HTML # htmltitleelement |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
HTMLTitleElement | ||||||||||||
text |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
- 实现此接口的 HTML 元素:
<title>
。