`
rebecca
  • 浏览: 311599 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

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的是少了“!”

 

分享到:
评论

相关推荐

    再谈ie和firefox下的document.all属性

    例如下面的代码: 代码如下: &lt;... &lt;body&gt; [removed] &lt;!– if(document.all) alert&#40;... 但这样是不能直接就认为在 firefox中 是不支持 document.all属性方法的。 下面一段代码,在IE和firefox浏览器

    解决 firefox 不支持 document.all的方法

    解决 firefox 不支持 document.all的方法

    记录几个javascript有关的小细节

    Firefox 支持 innerHTML 属性却不支持 innerText,如果不想用innerHTML 替代,可以用如下代码 由于Firefox不支持document.all,所以考虑兼容的时候获取对象通常用 document.getelementbyid(‘yourid’)....

    浏览器兼容的JS写法总结

     (1)现有问题:Firefox不支持document.all[name]  (2)解决方法:使用getElementsByName(name),getElementById(id)等来替代。 2. 集合类对象问题  (1)现有问题:IE中对许多集合类对象取用时可以用 (),但在Fire...

    图库新版jQuery焦点图 JS代码

    document.write('&lt;script type="text/javascript" &gt;BAIDU_CLB_SLOT_ID = "288992";&lt;/script&gt;'); document.write(ojs);} if (code=="top210x90_2"){ document.write('&lt;script type="text/javascript" &gt;BAIDU_CLB_SLOT...

    asp.net菜单(很简单)

    dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, previousmenuitem:null, currentpageurl: window.location.href.replace("http://"+window.location.hostname, "")....

    Javascript 兼容firefox的一些问题

    document.all() 在FF里不行. 必须改成document.getElementById(); 2. obj.innerText = “XXX”; 在FF里好像偶尔也有问题. 换成obj[removed] = “XXX”;就行了. 3. var olE = document.body.onload; 获得body的...

    javascript firefox兼容ie的dom方法脚本

    if(!document.all){ //zzcv的ff ie兼容脚本 /*脚本没有解决的问题及处理: 2.IE下,可以使用()或[]获取集合类对象;Firefox下,只能使用[]获取集合类对象. 解决方法:统一使用[]获取集合类对象....Firefox下则不能. 5

    IE浏览器兼容Firefox的JS脚本的代码

    父控件下的子控件 8.XmlHttp 1.window.event兼容脚本 function getEvent(){ //获取浏览器事件,同时兼容ie和ff的写法 if(document.all) return window.event; func=getEvent.caller; while(func!=null){ var arg0=...

    IE和火狐中模仿Click事件及提交到新窗口总结(asp.net)

    先看一下模拟click事件的代码: 代码如下: &lt;a&gt;... } else { //火狐,如果中没有定义onclick事件,则本段对火狐不起作用 var ev = document.createEvent(“MouseEvents”); ev.initEvent(“click”, true, true); docu

    关于js获取radio和select的属性并控制的代码

       首先是获得点击radio的事件,用的是jquery库,获得事件后判断是那个radio,通过判断是那个radio被checked了然后... 兼容ie和firefox用了var ie=document.all;var nn6=document.getElementById&&!document.all;  

    JAVASCRIPT下判断IE与FF的比较简单的方式

    但是过程相对复杂一点,... }else{ //FIREFOX opener.location.reload(); } window.close(); [removed]document.all这个属性,IE下可以使用,而FF下不能使用,利用这一点。就可以针对 不同的浏览器,来执行对应的程序。

    设为首页和收藏的Javascript代码(亲测兼容IE,Firefox,chrome等浏览器)

    由于chrome,safari,opara 浏览器还未支持自动 “设为首页” & “加入收藏”....加入收藏: 代码如下:function addFavorite(){ if (document.all){ try{ window.external.addFavorite[removed].href,document.titl

    兼容IE和Firefox的javascript获取iframe文档内容的函数

    代码如下: [removed] function getIframeContent(){ //获取iframe中文档内容 var doc;... }else{//Firefox doc = document.getElementById(“MyIFrame”).contentDocument; } return doc.body[removed]; } [removed]

    JavaScript判断访问的来源是手机还是电脑,用的哪种浏览器

    js 判断是什么类型浏览器 代码如下: if ( window.sidebar && “object” == typeof( window.sidebar ) && “function” == typeof( window.sidebar.addPanel ) ) // firefox { } else if ( document.all && ...

    用js判断浏览器是否是IE的比较好的办法

    一般常用方法是document.all if(document.all){ //IE代码 }else{ //其他 } 其实这么做不够,document.all能区分出FireFox,却无法区分Opera,因为Opera支持document.all. 我现在的做法是: var isIE = document....

    JS判断浏览器类型与版本的实现代码

    在众多的浏览器产品中,IE、Firefox、Opera、Safari……..众多品牌却标准不一,因此时常需要根据不同的浏览器,甚至相同浏览器不同版本做不同的操作,因此,知晓浏览器的判断方法,还是很重要的。下面列举一下常用的...

Global site tag (gtag.js) - Google Analytics