Body background属性

Body 对象参考手册Body オブジェクト

定義と使い方

background 属性は body 要素の background 属性の値を設定または返します。

background 属性はドキュメントの背景画像を表します。

構文

bodyObject.background=URL


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザが background 属性をサポートしています。


例

例

body 要素の background 属性の値を返す:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプルチュートリアル(example.com)</title>
</head>
<body id="logo" background="logo.png">

<script>
document.write("背景画像は: ")
document.write(document.getElementById("logo").background);
</script>

</body>
</html>

試してみる »


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