Anchor type 属性

定义和用法

type 属性设置或返回链接的 type 属性 的值。

type 属性规定被链接文档的 MIME 类型。

提示:type 属性纯粹是建议性的。

注释:type 属性 是 HTML5 中 <a> 元素的新属性。

实例

例子 1

返回特定链接的 MIME 类型:

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

亲自试一试

例子 2

将链接的 type 属性设置为 text/html:

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

亲自试一试

语法

返回 type 属性:

anchorObject.type

设置 type 属性:

anchorObject.type = MIME-type

Attribute value

Value Description
MIME-type

Specify the MIME type of the linked document.

Please see IANA MIME types, to get the complete list of standard MIME types.

Technical details

Return value: String value, representing the MIME type of the linked document.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related pages

HTML reference manual:HTML <a> type attribute