1. /*
  2. * Copyright (c) 2000 World Wide Web Consortium,
  3. * (Massachusetts Institute of Technology, Institut National de
  4. * Recherche en Informatique et en Automatique, Keio University). All
  5. * Rights Reserved. This program is distributed under the W3C's Software
  6. * Intellectual Property License. This program is distributed in the
  7. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
  10. * details.
  11. */
  12. package org.w3c.dom.html;
  13. import org.w3c.dom.Document;
  14. import org.w3c.dom.NodeList;
  15. /**
  16. * An <code>HTMLDocument</code> is the root of the HTML hierarchy and holds
  17. * the entire content. Besides providing access to the hierarchy, it also
  18. * provides some convenience methods for accessing certain sets of
  19. * information from the document.
  20. * <p> The following properties have been deprecated in favor of the
  21. * corresponding ones for the <code>BODY</code> element: alinkColor background
  22. * bgColor fgColor linkColor vlinkColor In DOM Level 2, the method
  23. * <code>getElementById</code> is inherited from the <code>Document</code>
  24. * interface where it was moved.
  25. * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
  26. */
  27. public interface HTMLDocument extends Document {
  28. /**
  29. * The title of a document as specified by the <code>TITLE</code> element
  30. * in the head of the document.
  31. */
  32. public String getTitle();
  33. public void setTitle(String title);
  34. /**
  35. * Returns the URI of the page that linked to this page. The value is an
  36. * empty string if the user navigated to the page directly (not through a
  37. * link, but, for example, via a bookmark).
  38. */
  39. public String getReferrer();
  40. /**
  41. * The domain name of the server that served the document, or
  42. * <code>null</code> if the server cannot be identified by a domain name.
  43. */
  44. public String getDomain();
  45. /**
  46. * The complete URI of the document.
  47. */
  48. public String getURL();
  49. /**
  50. * The element that contains the content for the document. In documents
  51. * with <code>BODY</code> contents, returns the <code>BODY</code>
  52. * element. In frameset documents, this returns the outermost
  53. * <code>FRAMESET</code> element.
  54. */
  55. public HTMLElement getBody();
  56. public void setBody(HTMLElement body);
  57. /**
  58. * A collection of all the <code>IMG</code> elements in a document. The
  59. * behavior is limited to <code>IMG</code> elements for backwards
  60. * compatibility.
  61. */
  62. public HTMLCollection getImages();
  63. /**
  64. * A collection of all the <code>OBJECT</code> elements that include
  65. * applets and <code>APPLET</code> ( deprecated ) elements in a document.
  66. */
  67. public HTMLCollection getApplets();
  68. /**
  69. * A collection of all <code>AREA</code> elements and anchor (
  70. * <code>A</code> ) elements in a document with a value for the
  71. * <code>href</code> attribute.
  72. */
  73. public HTMLCollection getLinks();
  74. /**
  75. * A collection of all the forms of a document.
  76. */
  77. public HTMLCollection getForms();
  78. /**
  79. * A collection of all the anchor (<code>A</code> ) elements in a document
  80. * with a value for the <code>name</code> attribute. Note. For reasons
  81. * of backwards compatibility, the returned set of anchors only contains
  82. * those anchors created with the <code>name</code> attribute, not those
  83. * created with the <code>id</code> attribute.
  84. */
  85. public HTMLCollection getAnchors();
  86. /**
  87. * The cookies associated with this document. If there are none, the
  88. * value is an empty string. Otherwise, the value is a string: a
  89. * semicolon-delimited list of "name, value" pairs for all the cookies
  90. * associated with the page. For example,
  91. * <code>name=value;expires=date</code> .
  92. */
  93. public String getCookie();
  94. public void setCookie(String cookie);
  95. /**
  96. * Note. This method and the ones following allow a user to add to or
  97. * replace the structure model of a document using strings of unparsed
  98. * HTML. At the time of writing alternate methods for providing similar
  99. * functionality for both HTML and XML documents were being considered.
  100. * The following methods may be deprecated at some point in the future in
  101. * favor of a more general-purpose mechanism.
  102. * <br> Open a document stream for writing. If a document exists in the
  103. * target, this method clears it.
  104. */
  105. public void open();
  106. /**
  107. * Closes a document stream opened by <code>open()</code> and forces
  108. * rendering.
  109. */
  110. public void close();
  111. /**
  112. * Write a string of text to a document stream opened by
  113. * <code>open()</code> . The text is parsed into the document's structure
  114. * model.
  115. * @param text The string to be parsed into some structure in the
  116. * document structure model.
  117. */
  118. public void write(String text);
  119. /**
  120. * Write a string of text followed by a newline character to a document
  121. * stream opened by <code>open()</code> . The text is parsed into the
  122. * document's structure model.
  123. * @param text The string to be parsed into some structure in the
  124. * document structure model.
  125. */
  126. public void writeln(String text);
  127. /**
  128. * Returns the (possibly empty) collection of elements whose
  129. * <code>name</code> value is given by <code>elementName</code> .
  130. * @param elementName The <code>name</code> attribute value for an
  131. * element.
  132. * @return The matching elements.
  133. */
  134. public NodeList getElementsByName(String elementName);
  135. }