代码先行。。以下是我的测试代码<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
window.onload = function(){
alert(document.getElementById("Box"));
}
</script>
</head>
<body>
<div id="Parent"></div>
<script language="javascript" type="text/javascript">
var divElement = document.createElement("div");
divElement.setAttribute("ID","Box");
document.getElementById("Parent").appendChild(divElement);
</script>
</body>
</html>这代码在FF下是正确的。但是IE下就行不通了
这里应该怎么处理???
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
window.onload = function(){
alert(document.getElementById("Box"));
}
</script>
</head>
<body>
<div id="Parent"></div>
<script language="javascript" type="text/javascript">
var divElement = document.createElement("div");
divElement.setAttribute("ID","Box");
document.getElementById("Parent").appendChild(divElement);
</script>
</body>
</html>这代码在FF下是正确的。但是IE下就行不通了
这里应该怎么处理???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货