首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

FF不支持javascript的for in语句吗?解决方案

2012-02-21 
FF不支持javascript的for in语句吗?!DOCTYPEhtmlPUBLIC-//W3C//DTDHTML4.01Transitional//EN http://w

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=

热点排行
Bad Request.