Link type属性
Link オブジェクト
定義と使用方法
type 属性は、リンクされた文書のタイプ(MIME タイプ)を設定または返します。
ヒント:MIME タイプの例: "text/css"、"text/javascript"、"image/gif" など。
構文
type 属性を設定する:
linkObject.type="MIME-type"
type 属性を返す:
linkObject.type
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが type 属性をサポートしています
例
例
リンクされた文書の MIME タイプを表示する:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<link id="link1" rel="stylesheet" type="text/css" href="style1.css.html">
<script>
function displayResult(){
var x=document.getElementById("link1").type;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">リンク要素の MIME タイプを表示</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<link id="link1" rel="stylesheet" type="text/css" href="style1.css.html">
<script>
function displayResult(){
var x=document.getElementById("link1").type;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">リンク要素の MIME タイプを表示</button>
</body>
</html>
試してみる »
Link オブジェクト その他の拡張