Anchor type attribute

Definition and Usage

type The attribute sets or returns the MIME type of the link type attribute Value.

type The attribute specifies the MIME type of the linked document.

Tip:type The attribute is purely advisory.

Note:type attribute It is a new attribute of the <a> element in HTML5.

Example

Example 1

Return the MIME type of a specific link:

var x = document.getElementById("myAnchor").type;

Try it yourself

Example 2

Set the type attribute of the link to text/html:

document.getElementById("myAnchor").type = "text/html";

Try it yourself

Syntax

Return the type attribute:

anchorObject.type

Set the type attribute:

anchorObject.type = MIME-type

属性值

描述
MIME-type

规定链接文档的 MIME 类型。

请查看 IANA MIME 类型,以获取标准 MIME 类型的完整列表。

技术细节

返回值: 字符串值,表示链接文档的 MIME 类型。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持

相关页面

HTML 参考手册:HTML <a> type 属性