JavaScript之HTMLDocument接口

1 interface Document : Node

2 {

3 //文档类型

4 readonly attribute DocumentType doctype;

5 //DOM实现对象

6 readonly attribute DOMImplementation implentation;

7 //文档根结点

8 readonly attribute Element documentElement;

9 //创建一个新元素

10 Element createElement(in DOMString tagName) raises(DOMException);

11 //创建文档片段

12 DOcumentFragment createDocumentFragment();

13 //创建文本结点

14 Text createTextNode(in DOMString data);

15 //创建注释结点

16 Comment createCommnet(in DOMString data);

17 //创建CDATA片段

18 CDATASection createCDATASection(in DOMString data) raises(DMDException);

19 //创建处理指令结点

20 ProcessingInstruction createProcessingInstruction(in DOMString target,in DOMString data) raises (DOMException);

21 //创建属性

22 Attr createAttribute(in DOMString name) raises(DOMException);

23 //创建实体引用

24 EntityReference createEntityReference(in DOMString name) raises(DOMException);

25 //根据便签名获取元素的列表

26 NodeList getElementsByTagName(in DOMString tagname);

27 }

1 interface HTMLDocument : Document

2 {

3 //文档标题

4 attribute DOMString title;

5 //将浏览器引入当前页面的URI

6 readonly attribute DOMString referrer;

7 文档所在的域名

8 readonly attribute DOMString domain;

9 完整的文档URI

10 readonly attribute DOMString URL;

11 //包含文档内容的元素

12 //对于普通文档body属性将返回body结点

13 //对于多框架文档,波电压属性将返回最上层的Frameset结点

14 attribute HTMLElement body;

15 //文档中所有的图像元素

16 readonly attribute HTMLCollection images;

17 //文档中所有的applet元素

18 readonly attribute HTMLCollection applets;

19 //文档中所有的链接

20 readonly attribute HTMLCollection links;

21 //文档中所有的表单

22 readonly attribute HTMLColletion forms;

23 //文档中所有的锚

24 readonly attribute HTMLCollection anchors;

25 //Cookie

26 attribute DOMString cookies;

27 //打开文档输入流准备写入

28 void open();

29 //关闭文档输入流,强制页面更新

30 void close();

31 //在文档中输出文本

32 void write(in DOMString text);

33 //在文档中输出文本,最后带有换行符

34 void writeln(in DOMString text);

35 //根据id值返回相应的元素

36 ELement getElementById(in DOMString elementId);

37 //根据name属性返回元素的列表

38 NodeList getElementsByName(in DOMString elementName);

39 }