Firefox Javascript: Why does .all not work? - Stack Overflow

In IE, I can go like:var x = document.getElementById("header");alert(x.all[0].tagName);If I t

In IE, I can go like:

var x = document.getElementById("header");

alert(x.all[0].tagName);

If I try that in Firefox, I get the error "all is undefined".

What is the Firefox equivalent of IE's .all property?

In IE, I can go like:

var x = document.getElementById("header");

alert(x.all[0].tagName);

If I try that in Firefox, I get the error "all is undefined".

What is the Firefox equivalent of IE's .all property?

Share Improve this question edited Jul 30, 2012 at 18:28 Rustam 1,9332 gold badges16 silver badges35 bronze badges asked Apr 14, 2011 at 16:12 oscilatingcretinoscilatingcretin 11k41 gold badges128 silver badges214 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

.all is a Microsoft-specific extension to the DOM, and is not supported by any other browsers (except Opera, I believe, who simulate it in order to improve patibility with sites written for IE).

You can use things like x.children and x.childNodes, or x.getElementById() and x.getElementsByTagName() to reference elements below the current one in the tree, depending on your usage. I suspect in this case x.children is what you're after.

all would be the name of an array. It is not a native javascript keyword.

You may want to look at childNodes instead.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745241387a4618202.html

相关推荐

  • Firefox Javascript: Why does .all not work? - Stack Overflow

    In IE, I can go like:var x = document.getElementById("header");alert(x.all[0].tagName);If I t

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信