HTML DOM Body background 屬性
定義和用法
background 屬性可設置或者返回body 元素background屬性的值。
background 屬性描述了文檔的背景圖片。
語法
bodyObject.background=URL
瀏覽器支持
所有主要瀏覽器都支持background 屬性。
實例
實例
返回body 元素的background屬性值:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body id="logo" background="logo.png">
<script>
document.write("背景图片是: ")
document.write(document.getElementById("logo").background);
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body id="logo" background="logo.png">
<script>
document.write("背景图片是: ")
document.write(document.getElementById("logo").background);
</script>
</body>
</html>
嘗試一下»
Body對象