document.all Firefox不支持

火狐并不支持  document.all

 

测试如下:

 

html代码:

 <!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>Document.All Example</title>  
 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />  
 </head>  
 <body>  
 <h1>Example Heading</h1>  
 <hr />  
 <p>This is a <em>paragraph</em>. It is only a <em>paragraph.</em></p>  
 <p>Yet another <em>paragraph.</em></p>  
 <p>This final <em>paragraph</em> has <em id="special">special emphasis.</em></p>  
 <hr />  
 <script type="text/javascript">  

//alert(document.all.length);      // Firefox下不支持

//alert(document.getElementById.length); //火狐下为1,谷歌下为0,IE下为未定义,反正都不为空。

alert(document.getElementsByTagName("*") .length);  //都支持
 
 </script>  
 </body>  
 </html> 

 输出情况,IE下18个,谷歌下17个,火狐不支持!!!

 

 可以使用document.getElementsByTagName("*")得到所有元素啊!!!!

 

 

其中他们分别代表:

 

document.all.length=18

document.all[0]=!

document.all[1]=HTML

document.all[2]=HEAD

document.all[3]=TITLE

document.all[4]=META

document.all[5]=BODY

document.all[6]=H1

document.all[7]=HR

document.all[8]=P

document.all[9]=EM

document.all[10]=EM

document.all[11]=P

document.all[12]=EM

document.all[13]=P

document.all[14]=EM

document.all[15]=EM

document.all[16]=HR

document.all[17]=SCRIPT

 

得到17的是少了“!”

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值