日期:2014-05-16  浏览次数:20304 次

Js 设置页面背景色,设置背景图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function abc(){
	var xx = document.getElementById("key");
	xx.style.color = "#55FF99";
	xx.style.backgroundImage="url(2.gif)"; //注意是backgroundImage
	xx.style.width = "100px";
	xx.style.height = "100px";
	 //document.body.style.backgroundImage="url(http://www.iteye.com/upload/logo/user/37073/648c9ed4-f54b-3f4a-ac54-905f5a483307.gif?1236833802)"; 
}
</script>
</head>

<body onload="abc();">
<div id="key" >ddd</div>
</body>
</html>

?