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 Link icon

  • Method Details Link icon

    • getURL Link icon

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

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

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

      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 Link icon

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

      HTMLCollection getCommands()

      getCommands.

      Returns:
      a HTMLCollection object.
    • getBgColor Link icon

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

      @Deprecated void setBgColor(String bgColor)
      Deprecated.

      setBgColor.

      Parameters:
      bgColor - a String object.
    • getBody Link icon

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

      void setBody(HTMLElement body)

      setBody.

      Parameters:
      body - a HTMLElement object.
    • getCharacterSet Link icon

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

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

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

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

      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 Link icon

      void setCookie(String cookie)

      setCookie.

      Parameters:
      cookie - a String object.
    • getCurrentScript Link icon

      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 Link icon

      Window getDefaultView()

      getDefaultView.

      Returns:
      a Window object.
    • getDesignMode Link icon

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

      void setDesignMode(String designMode)

      setDesignMode.

      Parameters:
      designMode - a String object.
    • getDir Link icon

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

      void setDir(String dir)

      setDir.

      Parameters:
      dir - a String object.
    • getDoctype Link icon

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

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

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

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

      void setDomain(String domain)

      setDomain.

      Parameters:
      domain - a String object.
    • getEmbeds Link icon

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

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

      void setFgColor(String fgColor)

      setFgColor.

      Parameters:
      fgColor - a String object.
    • getForms Link icon

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

      @Deprecated boolean isFullscreen()
      Deprecated.

      isFullscreen.

      Returns:
      a boolean.
    • isFullscreenEnabled Link icon

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

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

      boolean isHidden()

      isHidden.

      Returns:
      a boolean.
    • getImages Link icon

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

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

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

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

      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 Link icon

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

      void setLocation(Location location)

      setLocation.

      Parameters:
      location - a Location object.
    • getOrigin Link icon

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

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

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

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

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

      Element getScrollingElement()

      getScrollingElement.

      Returns:
      a Element object.
    • getTitle Link icon

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

      void setTitle(String title)

      setTitle.

      Parameters:
      title - a String object.
    • getVisibilityState Link icon

      VisibilityState getVisibilityState()

      getVisibilityState.

      Returns:
      a VisibilityState object.
    • adoptNode Link icon

      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 Link icon

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

      caretRangeFromPoint.

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

      @Deprecated void clear()
      Deprecated.

      clear.

    • close Link icon

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

      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 Link icon

      Attr createAttributeNS(String namespace, String qualifiedName)

      createAttributeNS.

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

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

      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 Link icon

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

      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 Link icon

      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 Link icon

      Element createElementNS(String namespace, String qualifiedName)

      createElementNS.

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

      Event createEvent(String eventInterface)

      createEvent.

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      boolean execCommand(String commandId, boolean showUI)

      execCommand.

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

      boolean execCommand(String commandId)

      execCommand.

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      String getXmlEncoding()

      getXmlEncoding.

      Returns:
      a String object.
    • getXmlVersion Link icon

      String getXmlVersion()

      getXmlVersion.

      Returns:
      a String object.
    • getXmlStandalone Link icon

      boolean getXmlStandalone()

      getXmlStandalone.

      Returns:
      a boolean.
    • getStrictErrorChecking Link icon

      boolean getStrictErrorChecking()

      getStrictErrorChecking.

      Returns:
      a boolean.
    • getDomConfig Link icon

      DOMConfiguration getDomConfig()

      getDomConfig.

      Returns:
      a DOMConfiguration object.
    • setDocumentURI Link icon

      void setDocumentURI(String documentURI)

      setDocumentURI.

      Parameters:
      documentURI - a String object.
    • setStrictErrorChecking Link icon

      void setStrictErrorChecking(boolean strictErrorChecking)

      setStrictErrorChecking.

      Parameters:
      strictErrorChecking - a boolean.
    • setXmlStandalone Link icon

      void setXmlStandalone(boolean xmlStandalone)

      setXmlStandalone.

      Parameters:
      xmlStandalone - a boolean.
    • setXmlVersion Link icon

      void setXmlVersion(String xmlVersion)

      setXmlVersion.

      Parameters:
      xmlVersion - a String object.
    • hasFocus Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      Document open(String url, String name)

      open.

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

      Document open(String url)

      open.

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

      Document open()

      open.

      Returns:
      a Document object.
    • queryCommandEnabled Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      @Deprecated void releaseEvents()
      Deprecated.

      releaseEvents.

    • write Link icon

      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 Link icon

      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 Link icon

      void normalizeDocument()

      normalizeDocument.

    • createExpression Link icon

      XPathExpression createExpression()

      createExpression.

      Returns:
      a XPathExpression object.
    • createNSResolver Link icon

      XPathNSResolver createNSResolver(Node nodeResolver)

      createNSResolver.

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

      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 Link icon

      EntityReference createEntityReference(String ent1)
    • renameNode Link icon

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

      boolean isXml()
    • setXml Link icon

      void setXml(boolean xml)