document.getElementById('gun').innerHTML='<img src="loading1.gif" />';就是这样的代码,执行的时候,在IE6里不行,在IE7里可以,可以把那段文字替换成 滚动 的图片,图片只有1K。为什么IE6 不会显示呢?但是如果我在网页中事先写入那张滚动图片隐藏的。<img src="loading1.gif" width="100" height="9" style="display:none" />在IE6中又可以了,为什么呢?
调试欢乐多
可能是你的IE6环境有问题或者代码不是够规范。我用以下代码在IE6环境下已测试成功!如果楼主用下面代码测试失败的话估计就是浏览器的原因了。
<!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>
<title> new document </title>
<style>
#gun {border:1px solid #F00;height:200px;width:200px;}
#gun img {height:200px;width:200px;}
</style>
</head> <body>
<div id="gun"></div>
<input type="button" value="添加图片" onclick="add()" />
<input type="button" value="删除图片" onclick="del()" />
<script type="text/javascript">
<!--
function add(){
document.getElementById('gun').innerHTML='<img src="loading.jpg" />';
}
function del(){
document.getElementById('gun').innerHTML='';
} //-->
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<style>
#gun {border:1px solid #F00;height:200px;width:200px;}
#gun img {height:200px;width:200px;}
</style>
</head> <body>
<div id="gun"></div>
<input type="button" value="添加图片" onclick="add()" />
<input type="button" value="删除图片" onclick="del()" />
<script type="text/javascript">
<!--
function add(){
document.getElementById('gun').innerHTML='<img src="loading.jpg" />';
}
function del(){
document.getElementById('gun').innerHTML='';
} //-->
</script>
</body>
</html>