[转]firefox与IE的background属性backgroundImage

本文转自:http://bbs.blueidea.com/archiver/tid-2804690.html

原文如下:

xbj126 发表于 2007-10-30 11:36

用javascript更改background属性,firefox不支持,请求解决方法

我的代码如下

document.getElementById("news").background = "images/news_bg3.gif";

IE可以正常运行
firefox却不行,请高手帮忙解决

sunritz 发表于 2007-10-30 11:42

[html]
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function bg(){
document.getElementById("news").style.backgroundImage = "url(http://bbs.blueidea.com/images/blue/logo.gif)";

}
</script>
</head>
<body onload="bg()">
<div id=news>
asfafdf
</div>
</body>
</html>
[/html]

posted on 2009-02-06 13:37  freeliver54  阅读(1291)  评论(0编辑  收藏  举报

导航