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

FF不支持javascript的for in语句吗?
<!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=GB18030 ">
<title> Insert   title   here </title>
</head>
<body>
<p   id= "test "> </p>
<script   type= "text/javascript ">
for   (i   in   window){
  test.innerHTML   =   test.innerHTML+i+ " <br> ";
}
</script>
</body>
</html>

 

上面在代码什么在P标签在FF中没有任何输出,而在IE和OPERA则有输出?

 



------解决方案--------------------
那是因为在FF下不能直接用ID来引用元素
用document.getElementById( "test ").innerHTML=