HTMLAnchorElement: type 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

HTMLAnchorElement 介面的 type 屬性是一個字串,表示連結資源的 MIME 型別。

它反映了 <a> 元素的 type 屬性。

字串。

示例

html
<a id="exampleLink" href="https://example.com" type="text/html">Example Link</a>
<p class="type"></p>
css
#exampleLink {
  font-size: 1.5rem;
}
js
const anchorElement = document.getElementById("exampleLink");
const pTag = document.querySelector(".type");
console.log(anchorElement.type); // Output: "text/html"
pTag.textContent = anchorElement.type;

規範

規範
HTML
# dom-a-type

瀏覽器相容性

另見