Latest web development tutorials

HTML DOM Anchor type 屬性

Anchor 對象參考手冊 Anchor對象

定義和用法

type 屬性可設置或返回被鏈資源的MIME 類型。

type 屬性描述了鏈接文檔的MIME 類型。

語法

設置type 屬性:

anchorObject.type="MIME-type"

返回type 屬性:

anchorObject.type

描述
MIME-type 描述链接文档的 MIME 类型。 更多关于 MIME 类型请查看 IANA MIME types


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持type 屬性


實例

實例

下面的例子可返回被鏈資源的MIME 類型:

<html>
<body>

<p><a id="w3s" type="text/html"
href="http://www.w3cschool.cc">W3Schools</a></p>

<script>
document.write(document.getElementById("w3s").type);
</script>

</body>
</html>

以上實例輸出結果:

text/html

嘗試一下»


Anchor 對象參考手冊 Anchor對象