pub struct Document(/* private fields */);
Expand description
The Document
interface represents any web page loaded in the browser and
serves as an entry point into the web page’s content, which is the DOM tree.
Implementations§
Source§impl Document
impl Document
Sourcepub fn create_document_fragment(&self) -> DocumentFragment
pub fn create_document_fragment(&self) -> DocumentFragment
In an HTML document, the Document.createDocumentFragment() method creates a new empty DocumentFragment.
Sourcepub fn create_element(
&self,
tag: &str,
) -> Result<Element, InvalidCharacterError>
pub fn create_element( &self, tag: &str, ) -> Result<Element, InvalidCharacterError>
In an HTML document, the Document.createElement() method creates the HTML
element specified by tag
, or an HTMLUnknownElement if tag
isn’t
recognized. In other documents, it creates an element with a null namespace URI.
Sourcepub fn create_element_ns(
&self,
namespace_uri: &str,
tag: &str,
) -> Result<Element, CreateElementNsError>
pub fn create_element_ns( &self, namespace_uri: &str, tag: &str, ) -> Result<Element, CreateElementNsError>
Creates an element with the specified namespace URI and qualified name.
To create an element without specifying a namespace URI, use the createElement
method.
Sourcepub fn create_text_node(&self, text: &str) -> TextNode
pub fn create_text_node(&self, text: &str) -> TextNode
Creates a new text node.
Sourcepub fn location(&self) -> Option<Location>
pub fn location(&self) -> Option<Location>
Returns a Location object which contains information about the URL of the document and provides methods for changing that URL and loading another URL.
Sourcepub fn body(&self) -> Option<HtmlElement>
pub fn body(&self) -> Option<HtmlElement>
Returns the <body>
or <frameset>
node of the current document, or null if no such element exists.
Sourcepub fn head(&self) -> Option<HtmlElement>
pub fn head(&self) -> Option<HtmlElement>
Returns the <head>
element of the current document. If there are more than one <head>
elements, the first one is returned.
Sourcepub fn document_element(&self) -> Option<Element>
pub fn document_element(&self) -> Option<Element>
Returns the Element that is the root element of the document (for example, the <html>
element for HTML documents).
Sourcepub fn pointer_lock_element(&self) -> Option<Element>
pub fn pointer_lock_element(&self) -> Option<Element>
Returns the Element that the pointer is locked to, if it is locked to any
Sourcepub fn exit_pointer_lock(&self)
pub fn exit_pointer_lock(&self)
Exit the pointer lock on the current element
Sourcepub fn import_node<N: INode>(
&self,
n: &N,
kind: CloneKind,
) -> Result<Node, NotSupportedError>
pub fn import_node<N: INode>( &self, n: &N, kind: CloneKind, ) -> Result<Node, NotSupportedError>
Import node from another document
Sourcepub fn fullscreen_enabled(&self) -> bool
pub fn fullscreen_enabled(&self) -> bool
Check if the fullscreen API is enabled
Sourcepub fn fullscreen_element(&self) -> Option<Element>
pub fn fullscreen_element(&self) -> Option<Element>
Get the current fullscreen element, or None if there is nothing fullscreen
Trait Implementations§
Source§impl From<Document> for EventTarget
impl From<Document> for EventTarget
Source§impl IEventTarget for Document
impl IEventTarget for Document
Source§fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
EventTarget
on which it’s called. Read moreSource§impl INode for Document
impl INode for Document
Source§fn append_child<T: INode>(&self, child: &T)
fn append_child<T: INode>(&self, child: &T)
Source§fn remove_child<T: INode>(&self, child: &T) -> Result<Node, NotFoundError>
fn remove_child<T: INode>(&self, child: &T) -> Result<Node, NotFoundError>
Source§fn clone_node(&self, kind: CloneKind) -> Result<Self, TODO>
fn clone_node(&self, kind: CloneKind) -> Result<Self, TODO>
Source§fn contains<T: INode>(&self, node: &T) -> bool
fn contains<T: INode>(&self, node: &T) -> bool
Source§fn insert_before<T: INode, U: INode>(
&self,
new_node: &T,
reference_node: &U,
) -> Result<Node, InsertNodeError>
fn insert_before<T: INode, U: INode>( &self, new_node: &T, reference_node: &U, ) -> Result<Node, InsertNodeError>
Source§fn replace_child<T: INode, U: INode>(
&self,
new_child: &T,
old_child: &U,
) -> Result<Node, InsertNodeError>
fn replace_child<T: INode, U: INode>( &self, new_child: &T, old_child: &U, ) -> Result<Node, InsertNodeError>
Source§fn parent_node(&self) -> Option<Node>
fn parent_node(&self) -> Option<Node>
Source§fn first_child(&self) -> Option<Node>
fn first_child(&self) -> Option<Node>
None
if the node is childless. Read moreSource§fn last_child(&self) -> Option<Node>
fn last_child(&self) -> Option<Node>
None
if the node is childless. Read moreSource§fn next_sibling(&self) -> Option<Node>
fn next_sibling(&self) -> Option<Node>
None
if there isn’t such a node. Read moreSource§fn owner_document(&self) -> Option<Document>
fn owner_document(&self) -> Option<Document>
Document
that this node belongs to. Read moreSource§fn parent_element(&self) -> Option<Element>
fn parent_element(&self) -> Option<Element>
Element
that is the parent of this node. Returns null
if the node
has no parent or the parent is not an Element
. Read moreSource§fn previous_sibling(&self) -> Option<Node>
fn previous_sibling(&self) -> Option<Node>
None
if there isn’t such a node. Read moreSource§fn text_content(&self) -> Option<String>
fn text_content(&self) -> Option<String>
Source§fn set_text_content(&self, text: &str)
fn set_text_content(&self, text: &str)
Source§fn child_nodes(&self) -> NodeList
fn child_nodes(&self) -> NodeList
Source§fn has_child_nodes(&self) -> bool
fn has_child_nodes(&self) -> bool
Source§fn is_default_namespace(&self, namespace: &str) -> bool
fn is_default_namespace(&self, namespace: &str) -> bool
Source§fn is_equal_node<T: INode>(&self, node: &T) -> bool
fn is_equal_node<T: INode>(&self, node: &T) -> bool
Source§fn is_same_node<T: INode>(&self, node: &T) -> bool
fn is_same_node<T: INode>(&self, node: &T) -> bool
Node
references are the same. Read more