IFrame widthプロパティ

Frame/IFrame 对象参考手册Frame/IFrame オブジェクト

定義と用法

width プロパティは、iframe 要素の width プロパティの値を設定または返します。

width プロパティは、iframe の幅を指定します。

構文

iframeObject.width=value

width プロパティは次の値を指定できます:

值 説明
pixels ピクセル単位(例:"100px" または "100")
% パーセント幅(例:"20%")


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザは width プロパティをサポートしています。


例

例

iframe の高さと幅を変更:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function changeSize(){
    document.getElementById("myframe").height="300";
    document.getElementById("myframe").width="300";
}
</script>
</head>
<body>
    
<iframe id="myframe" src="../index.html" height="200" width="200">
<p>お使いのブラウザは iframe をサポートしていません。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSize()" value="サイズ変更">

</body>
</html>

試してみる »


Frame/IFrame 对象参考手册Frame/IFrame オブジェクトその他の拡張