火狐并不支持 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的是少了“!”
分享到:
相关推荐
例如下面的代码: 代码如下: <... <body> [removed] <!– if(document.all) alert(... 但这样是不能直接就认为在 firefox中 是不支持 document.all属性方法的。 下面一段代码,在IE和firefox浏览器
解决 firefox 不支持 document.all的方法
Firefox 支持 innerHTML 属性却不支持 innerText,如果不想用innerHTML 替代,可以用如下代码 由于Firefox不支持document.all,所以考虑兼容的时候获取对象通常用 document.getelementbyid(‘yourid’)....
(1)现有问题:Firefox不支持document.all[name] (2)解决方法:使用getElementsByName(name),getElementById(id)等来替代。 2. 集合类对象问题 (1)现有问题:IE中对许多集合类对象取用时可以用 (),但在Fire...
document.write('<script type="text/javascript" >BAIDU_CLB_SLOT_ID = "288992";</script>'); document.write(ojs);} if (code=="top210x90_2"){ document.write('<script type="text/javascript" >BAIDU_CLB_SLOT...
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, previousmenuitem:null, currentpageurl: window.location.href.replace("http://"+window.location.hostname, "")....
document.all() 在FF里不行. 必须改成document.getElementById(); 2. obj.innerText = “XXX”; 在FF里好像偶尔也有问题. 换成obj[removed] = “XXX”;就行了. 3. var olE = document.body.onload; 获得body的...
if(!document.all){ //zzcv的ff ie兼容脚本 /*脚本没有解决的问题及处理: 2.IE下,可以使用()或[]获取集合类对象;Firefox下,只能使用[]获取集合类对象. 解决方法:统一使用[]获取集合类对象....Firefox下则不能. 5
父控件下的子控件 8.XmlHttp 1.window.event兼容脚本 function getEvent(){ //获取浏览器事件,同时兼容ie和ff的写法 if(document.all) return window.event; func=getEvent.caller; while(func!=null){ var arg0=...
先看一下模拟click事件的代码: 代码如下: <a>... } else { //火狐,如果中没有定义onclick事件,则本段对火狐不起作用 var ev = document.createEvent(“MouseEvents”); ev.initEvent(“click”, true, true); docu
首先是获得点击radio的事件,用的是jquery库,获得事件后判断是那个radio,通过判断是那个radio被checked了然后... 兼容ie和firefox用了var ie=document.all;var nn6=document.getElementById&&!document.all;
但是过程相对复杂一点,... }else{ //FIREFOX opener.location.reload(); } window.close(); [removed]document.all这个属性,IE下可以使用,而FF下不能使用,利用这一点。就可以针对 不同的浏览器,来执行对应的程序。
由于chrome,safari,opara 浏览器还未支持自动 “设为首页” & “加入收藏”....加入收藏: 代码如下:function addFavorite(){ if (document.all){ try{ window.external.addFavorite[removed].href,document.titl
代码如下: [removed] function getIframeContent(){ //获取iframe中文档内容 var doc;... }else{//Firefox doc = document.getElementById(“MyIFrame”).contentDocument; } return doc.body[removed]; } [removed]
js 判断是什么类型浏览器 代码如下: if ( window.sidebar && “object” == typeof( window.sidebar ) && “function” == typeof( window.sidebar.addPanel ) ) // firefox { } else if ( document.all && ...
一般常用方法是document.all if(document.all){ //IE代码 }else{ //其他 } 其实这么做不够,document.all能区分出FireFox,却无法区分Opera,因为Opera支持document.all. 我现在的做法是: var isIE = document....
在众多的浏览器产品中,IE、Firefox、Opera、Safari……..众多品牌却标准不一,因此时常需要根据不同的浏览器,甚至相同浏览器不同版本做不同的操作,因此,知晓浏览器的判断方法,还是很重要的。下面列举一下常用的...