document.all 是什么意思?

hgy82 2004-03-25 11:55:29


<script language=javascript>
if(document.all) document.write(""+
"<frameset name=forum cols=230,* framespacing=0 frameborder=0 border=0 rows=*>"+"<frame name=left src=border.htm scrolling=no noresize>");
else document.write(""+
"<frameset name=forum cols=230,* framespacing=0 frameborder=0 border=0 rows=*>"+"<frame name=left src=left.jsp scrolling=no noresize>");
</script>
...全文
1823 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
gjd111686 2004-03-25
  • 打赏
  • 举报
回复
all

--------------------------------------------------------------------------------

Description

Returns an object reference to the collection of elements contained by the object.

Syntax
object.all(index)



Parameter Description
object An object that can contain elements such as the document.
(index) Optional. An integer or a string specifying the index value of the element to retrieve. Integer indexes are zero-based, meaning the first element in the collection has index 0. A string index is valid only if the string is a name or identifier of at least one element in the document.

Remarks

The all collection includes one element object for each valid HTML tag. If a valid tag has a matching end tag, both tags are represented by the same element object.

The collection returned by the document's all property always includes a reference to the HTML, HEAD, TITLE, and BODY objects regardless of whether the tags are present in the document.

If the document contains invalid or unknown tags, the collection includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own element objects. The order of the element objects is the HTML source order. Although the collection indicates the order of tags, it does not indicate hierarchy.

Examples

The following JScript example displays the names of all tags in the document in the order the tags appear in the document.

for(i=0; i<document.all.length; i++) {
alert(document.all(i).tagName);
}

The following JScript example uses the item method on the all collection to retrieve all element objects for which the name or ID attribute is set to "sample". Depending on how many times the name or ID is defined in the document, the item method may return null, a single element object, or a collection of element objects. The example uses the length property of the collection to determine whether item returned a collection or a single object.

var a = document.all.item("sample");
if (a!=null) {
if (a.length!=null) {
for (i=0; i<a.length; i++) {
alert(a(i).tagName);
}
} else
alert(a.tagName);
}

Property

length

Methods

item, tags

Applies To

A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, INS, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP

hgy82 2004-03-25
  • 打赏
  • 举报
回复
问题补充,

此页面的功能相当于 dreamveaver MX 的工作界面, 窗口右边的小窗口可以通过点击小三角号而打开或关闭, 它的判断条件就是 document.all 我大概知道 all 是说所有的对象, 但点击三角号时, 什么时候是 all 什么情况下不是all 呢? 请帮忙!
nhconch 2004-03-25
  • 打赏
  • 举报
回复
IE特有,NS没有
stefli 2004-03-25
  • 打赏
  • 举报
回复
在这里是起到判断是否是ie的功能,
if(document.all) //ie
if(document.layer) //ns
hgy82 2004-03-25
  • 打赏
  • 举报
回复
谢谢!不过我英文很差!












87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧