下面的代码显示了我在Firefox和Chrome中所期望的内容: 一个绿色的大矩形中的一个小白色正方形。 我没有看到IE7中的小方块。 我如何让它出现?在IE7中显示javascript生成的div
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
<!--
function start()
{
var g_Div = document.getElementById("bigdiv");
var littleDiv = document.createElement('div');
littleDiv.setAttribute('style',
'position:absolute;'+
'left:300px;'+
'top:300px;'+
'width:5px;'+
'height:5px;'+
'clip:rect(0pt,5px,5px,0pt);'+
'background-color: rgb(255, 255, 255);');
g_Div.appendChild(littleDiv);
}
//-->
</script>
</head>
<body>
<div
id="bigdiv"
style="border: 1px solid ; margin: auto; height: 600px; width: 800px; background-color: green;"
>
</div>
<script type="text/javascript">
<!--
start();
//-->
</script>
</body>
</html>
伟大的作品! (除了我不想要的黑色边框,但容易删除) – Fabien 2009-02-08 14:52:26