Interface Document

All Superinterfaces:
DocumentRange, DocumentTraversal, EventTarget, Node, NonElementParentNode, ParentNode
All Known Subinterfaces:
HTMLDocument, SMILDocument
All Known Implementing Classes:
DocumentImpl, DTMNodeProxy, HTMLDocumentImpl, XMLDocument

Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
  • Field Details

  • Method Details

    • getURL

      String getURL()
      Sets or gets the URL for the current document.
      Returns:
      a String object.
    • getActiveElement

      Element getActiveElement()
      Gets the object that has the focus when the parent document has focus.
      Returns:
      a Element object.
    • getall

      Deprecated.
      Returns a reference to the collection of elements contained by the object.
      Returns:
      a HTMLAllCollection object.
    • getAnchors

      Deprecated.
      Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order.
      Returns:
      a HTMLCollection object.
    • getApplets

      Deprecated.
      Retrieves a collection of all applet objects in the document.
      Returns:
      a HTMLCollection object.
    • getCommands

      HTMLCollection getCommands()

      getCommands.

      Returns:
      a HTMLCollection object.
    • getBgColor

      @Deprecated String getBgColor()
      Deprecated.
      Deprecated. Sets or retrieves a value that indicates the background color behind the object.
      Returns:
      a String object.
    • setBgColor

      @Deprecated void setBgColor(String bgColor)
      Deprecated.

      setBgColor.

      Parameters:
      bgColor - a String object.
    • getBody

      HTMLElement getBody()
      Specifies the beginning and end of the document body.
      Returns:
      a HTMLElement object.
    • setBody

      void setBody(HTMLElement body)

      setBody.

      Parameters:
      body - a HTMLElement object.
    • getCharacterSet

      String getCharacterSet()
      Returns document's encoding.
      Returns:
      a String object.
    • getCharset

      String getCharset()
      Gets or sets the character set used to encode the object.
      Returns:
      a String object.
    • getCompatMode

      String getCompatMode()
      Gets a value that indicates whether standards-compliant mode is switched on for the object.
      Returns:
      a String object.
    • getContentType

      String getContentType()
      Returns document's content type.
      Returns:
      a String object.
    • getCookie

      String getCookie()
      Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned.

      Can be set, to add a new cookie to the element's set of HTTP cookies.

      If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting.

      Returns:
      a String object.
    • setCookie

      void setCookie(String cookie)

      setCookie.

      Parameters:
      cookie - a String object.
    • getCurrentScript

      HTMLScriptElement getCurrentScript()
      Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing.

      Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script.

      Returns:
      a HTMLScriptElement object.
    • getDefaultView

      Window getDefaultView()

      getDefaultView.

      Returns:
      a Window object.
    • getDesignMode

      String getDesignMode()
      Sets or gets a value that indicates whether the document can be edited.
      Returns:
      a String object.
    • setDesignMode

      void setDesignMode(String designMode)

      setDesignMode.

      Parameters:
      designMode - a String object.
    • getDir

      String getDir()
      Sets or retrieves a value that indicates the reading order of the object.
      Returns:
      a String object.
    • setDir

      void setDir(String dir)

      setDir.

      Parameters:
      dir - a String object.
    • getDoctype

      DocumentType getDoctype()
      Gets an object representing the document type declaration associated with the current document.
      Returns:
      a DocumentType object.
    • getDocumentElement

      Element getDocumentElement()
      Gets a reference to the root node of the document.
      Returns:
      a Element object.
    • getDocumentURI

      String getDocumentURI()
      Returns document's URL.
      Returns:
      a String object.
    • getDomain

      String getDomain()
      Sets or gets the security domain of the document.
      Returns:
      a String object.
    • setDomain

      void setDomain(String domain)

      setDomain.

      Parameters:
      domain - a String object.
    • getEmbeds

      HTMLCollection getEmbeds()
      Retrieves a collection of all embed objects in the document.
      Returns:
      a HTMLCollection object.
    • getFgColor

      @Deprecated String getFgColor()
      Deprecated.
      Sets or gets the foreground (text) color of the document.
      Returns:
      a String object.
    • setFgColor

      void setFgColor(String fgColor)

      setFgColor.

      Parameters:
      fgColor - a String object.
    • getForms

      HTMLCollection getForms()
      Retrieves a collection, in source order, of all form objects in the document.
      Returns:
      a HTMLCollection object.
    • isFullscreen

      @Deprecated boolean isFullscreen()
      Deprecated.

      isFullscreen.

      Returns:
      a boolean.
    • isFullscreenEnabled

      boolean isFullscreenEnabled()
      Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise.
      Returns:
      a boolean.
    • getHead

      HTMLHeadElement getHead()
      Returns the head element.
      Returns:
      a HTMLHeadElement object.
    • isHidden

      boolean isHidden()

      isHidden.

      Returns:
      a boolean.
    • getImages

      HTMLCollection getImages()
      Retrieves a collection, in source order, of img objects in the document.
      Returns:
      a HTMLCollection object.
    • getImplementation

      DOMImplementation getImplementation()
      Gets the implementation object of the current document.
      Returns:
      a DOMImplementation object.
    • getInputEncoding

      String getInputEncoding()
      Returns the character encoding used to create the webpage that is loaded into the document object.
      Returns:
      a String object.
    • getLastModified

      String getLastModified()
      Gets the date that the page was last modified, if the page supplies one.
      Returns:
      a String object.
    • getLinks

      HTMLCollection getLinks()
      Retrieves a collection of all a objects that specify the href property and all area objects in the document.
      Returns:
      a HTMLCollection object.
    • getLocation

      Location getLocation()
      Contains information about the current URL.
      Returns:
      a Location object.
    • setLocation

      void setLocation(Location location)

      setLocation.

      Parameters:
      location - a Location object.
    • getOrigin

      String getOrigin()
      Returns document's origin.
      Returns:
      a String object.
    • getPlugins

      HTMLCollection getPlugins()
      Return an HTMLCollection of the embed elements in the Document.
      Returns:
      a HTMLCollection object.
    • getReadyState

      DocumentReadyState getReadyState()
      Retrieves a value that indicates the current state of the object.
      Returns:
      a DocumentReadyState object.
    • getReferrer

      String getReferrer()
      Gets the URL of the location that referred the user to the current page.
      Returns:
      a String object.
    • getScripts

      HTMLCollection getScripts()
      Retrieves a collection of all script objects in the document.
      Returns:
      a HTMLCollection object.
    • getScrollingElement

      Element getScrollingElement()

      getScrollingElement.

      Returns:
      a Element object.
    • getTitle

      String getTitle()
      Contains the title of the document.
      Returns:
      a String object.
    • setTitle

      void setTitle(String title)

      setTitle.

      Parameters:
      title - a String object.
    • getVisibilityState

      VisibilityState getVisibilityState()

      getVisibilityState.

      Returns:
      a VisibilityState object.
    • adoptNode

      Node adoptNode(Node source)
      Moves node from another document and returns it.

      If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException.

      Parameters:
      source - a Node object.
      Returns:
      a Node object.
    • caretRangeFromPoint

      @Deprecated Range caretRangeFromPoint(double x, double y)
      Deprecated.

      caretRangeFromPoint.

      Parameters:
      x - a double.
      y - a double.
      Returns:
      a Range object.
    • clear

      @Deprecated void clear()
      Deprecated.

      clear.

    • close

      void close()
      Closes an output stream and forces the sent data to display.
    • createAttribute

      Attr createAttribute(String localName)
      Creates an attribute object with a specified name.
      Parameters:
      localName - String that sets the attribute object's name.
      Returns:
      a Attr object.
    • createAttributeNS

      Attr createAttributeNS(String namespace, String qualifiedName)

      createAttributeNS.

      Parameters:
      namespace - a String object.
      qualifiedName - a String object.
      Returns:
      a Attr object.
    • createCDATASection

      CDATASection createCDATASection(String data)
      Returns a CDATASection node whose data is data.
      Parameters:
      data - a String object.
      Returns:
      a CDATASection object.
    • createComment

      Comment createComment(String data)
      Creates a comment object with the specified data.
      Parameters:
      data - Sets the comment object's data.
      Returns:
      a Comment object.
    • createDocumentFragment

      DocumentFragment createDocumentFragment()
      Creates a new document.
      Returns:
      a DocumentFragment object.
    • createElement

      Element createElement(String tagName)
      Creates an instance of the element for the specified tag.
      Parameters:
      tagName - The name of an element.
      Returns:
      a Element object.
    • createElementNS

      Element createElementNS(String namespace, String qualifiedName, String options)
      Returns an element with namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName.

      If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown.

      If one of the following conditions is true a "NamespaceError" DOMException will be thrown:

      localName does not match the QName production. Namespace prefix is not null and namespace is the empty string. Namespace prefix is "xml" and namespace is not the XML namespace. qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".

      When supplied, options's is can be used to create a customized built-in element.

      Parameters:
      namespace - a String object.
      qualifiedName - a String object.
      options - a String object.
      Returns:
      a Element object.
    • createElementNS

      Element createElementNS(String namespace, String qualifiedName)

      createElementNS.

      Parameters:
      namespace - a String object.
      qualifiedName - a String object.
      Returns:
      a Element object.
    • createEvent

      Event createEvent(String eventInterface)

      createEvent.

      Parameters:
      eventInterface - a String object.
      Returns:
      a Event object.
    • createProcessingInstruction

      ProcessingInstruction createProcessingInstruction(String target, String data)
      Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown.
      Parameters:
      target - a String object.
      data - a String object.
      Returns:
      a ProcessingInstruction object.
    • createTextNode

      Text createTextNode(String data) throws DOMException
      Creates a text string from the specified value.
      Parameters:
      data - String that specifies the nodeValue property of the text node.
      Returns:
      a Text object.
      Throws:
      DOMException
    • elementFromPoint

      Element elementFromPoint(double x, double y)
      Returns the element for the specified x coordinate and the specified y coordinate.
      Parameters:
      x - The x-offset
      y - The y-offset
      Returns:
      a Element object.
    • execCommand

      boolean execCommand(String commandId, boolean showUI, String value)
      Executes a command on the current document, current selection, or the given range.
      Parameters:
      commandId - String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script.
      showUI - Display the user interface, defaults to false.
      value - Value to assign.
      Returns:
      a boolean.
    • execCommand

      boolean execCommand(String commandId, boolean showUI)

      execCommand.

      Parameters:
      commandId - a String object.
      showUI - a boolean.
      Returns:
      a boolean.
    • execCommand

      boolean execCommand(String commandId)

      execCommand.

      Parameters:
      commandId - a String object.
      Returns:
      a boolean.
    • getElementById

      Element getElementById(String elementId)
      Returns the first element within node's descendants whose ID is elementId. Returns a reference to the first object with the specified value of the ID or NAME attribute.
      Specified by:
      getElementById in interface NonElementParentNode
      Parameters:
      elementId - a String object.
      Returns:
      a Element object.
    • getElementsByClassName

      HTMLCollection getElementsByClassName(String classNames)
      Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes.
      Parameters:
      classNames - a String object.
      Returns:
      a HTMLCollection object.
    • getElementsByName

      HTMLCollection getElementsByName(String elementName)
      Gets a collection of objects based on the value of the NAME or ID attribute.
      Parameters:
      elementName - Gets a collection of objects based on the value of the NAME or ID attribute.
      Returns:
      a HTMLCollection object.
    • getElementsByTagName

      HTMLCollection getElementsByTagName(String qualifiedName)
      Retrieves a collection of objects based on the specified element name.
      Parameters:
      qualifiedName - Specifies the name of an element.
      Returns:
      a HTMLCollection object.
    • getElementsByTagNameNS

      HTMLCollection getElementsByTagNameNS(String namespaceURI, String localName)
      If namespace and localName are "*" returns a HTMLCollection of all descendant elements.

      If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName.

      If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace.

      Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName.

      Parameters:
      namespaceURI - a String object.
      localName - a String object.
      Returns:
      a HTMLCollection object.
    • getSelection

      Selection getSelection()
      Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
      Returns:
      a Selection object.
    • getXmlEncoding

      String getXmlEncoding()

      getXmlEncoding.

      Returns:
      a String object.
    • getXmlVersion

      String getXmlVersion()

      getXmlVersion.

      Returns:
      a String object.
    • getXmlStandalone

      boolean getXmlStandalone()

      getXmlStandalone.

      Returns:
      a boolean.
    • getStrictErrorChecking

      boolean getStrictErrorChecking()

      getStrictErrorChecking.

      Returns:
      a boolean.
    • getDomConfig

      DOMConfiguration getDomConfig()

      getDomConfig.

      Returns:
      a DOMConfiguration object.
    • setDocumentURI

      void setDocumentURI(String documentURI)

      setDocumentURI.

      Parameters:
      documentURI - a String object.
    • setStrictErrorChecking

      void setStrictErrorChecking(boolean strictErrorChecking)

      setStrictErrorChecking.

      Parameters:
      strictErrorChecking - a boolean.
    • setXmlStandalone

      void setXmlStandalone(boolean xmlStandalone)

      setXmlStandalone.

      Parameters:
      xmlStandalone - a boolean.
    • setXmlVersion

      void setXmlVersion(String xmlVersion)

      setXmlVersion.

      Parameters:
      xmlVersion - a String object.
    • hasFocus

      boolean hasFocus()
      Gets a value indicating whether the object currently has focus.
      Returns:
      a boolean.
    • importNode

      Node importNode(Node importedNode, boolean deep)
      Returns a copy of node. If deep is true, the copy also includes the node's descendants.

      If node is a document or a shadow root, throws a "NotSupportedError" DOMException.

      Parameters:
      importedNode - a Node object.
      deep - a boolean.
      Returns:
      a Node object.
    • open

      Document open(String url, String name, String features, boolean replace)
      Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method.
      Parameters:
      url - Specifies a MIME type for the document.
      name - Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element.
      features - Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported.
      replace - Specifies whether the existing entry for the document is replaced in the history list.
      Returns:
      a Document object.
    • open

      Document open(String url, String name, String features)

      open.

      Parameters:
      url - a String object.
      name - a String object.
      features - a String object.
      Returns:
      a Document object.
    • open

      Document open(String url, String name)

      open.

      Parameters:
      url - a String object.
      name - a String object.
      Returns:
      a Document object.
    • open

      Document open(String url)

      open.

      Parameters:
      url - a String object.
      Returns:
      a Document object.
    • open

      Document open()

      open.

      Returns:
      a Document object.
    • queryCommandEnabled

      boolean queryCommandEnabled(String commandId)
      Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
      Parameters:
      commandId - Specifies a command identifier.
      Returns:
      a boolean.
    • queryCommandIndeterm

      boolean queryCommandIndeterm(String commandId)
      Returns a Boolean value that indicates whether the specified command is in the indeterminate state.
      Parameters:
      commandId - String that specifies a command identifier.
      Returns:
      a boolean.
    • queryCommandState

      boolean queryCommandState(String commandId)
      Returns a Boolean value that indicates the current state of the command.
      Parameters:
      commandId - String that specifies a command identifier.
      Returns:
      a boolean.
    • queryCommandSupported

      boolean queryCommandSupported(String commandId)
      Returns a Boolean value that indicates whether the current command is supported on the current range.
      Parameters:
      commandId - Specifies a command identifier.
      Returns:
      a boolean.
    • queryCommandValue

      String queryCommandValue(String commandId)
      Returns the current value of the document, range, or current selection for the given command.
      Parameters:
      commandId - String that specifies a command identifier.
      Returns:
      a String object.
    • releaseEvents

      @Deprecated void releaseEvents()
      Deprecated.

      releaseEvents.

    • write

      void write(String text)
      Writes one or more HTML expressions to a document in the specified window.
      Parameters:
      text - Specifies the text and HTML tags to write.
    • writeln

      void writeln(String text)
      Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.
      Parameters:
      text - The text and HTML tags to write.
    • normalizeDocument

      void normalizeDocument()

      normalizeDocument.

    • createExpression

      XPathExpression createExpression()

      createExpression.

      Returns:
      a XPathExpression object.
    • createNSResolver

      XPathNSResolver createNSResolver(Node nodeResolver)

      createNSResolver.

      Parameters:
      nodeResolver - a Node object.
      Returns:
      a XPathNSResolver object.
    • evaluate

      XPathResult evaluate(String expression, Node contextNode, XPathNSResolver resolver, short type, Object result)

      evaluate.

      Parameters:
      expression - a String object.
      contextNode - a Node object.
      resolver - a XPathNSResolver object.
      type - a short.
      result - a Object object.
      Returns:
      a XPathResult object.
    • createEntityReference

      EntityReference createEntityReference(String ent1)
    • renameNode

      Node renameNode(Node node, String namespaceURI, String qualifiedName)
    • isXml

      boolean isXml()
    • setXml

      void setXml(boolean xml)