pub struct XMLDocument { /* private fields */ }Expand description
The XMLDocument class.
XMLDocument
Methods from Deref<Target = Document>§
Sourcepub fn implementation(&self) -> DOMImplementation
pub fn implementation(&self) -> DOMImplementation
Getter of the implementation attribute.
Document.implementation
Sourcepub fn url(&self) -> JsString
pub fn url(&self) -> JsString
Getter of the URL attribute.
Document.URL
Sourcepub fn document_uri(&self) -> JsString
pub fn document_uri(&self) -> JsString
Getter of the documentURI attribute.
Document.documentURI
Sourcepub fn compat_mode(&self) -> JsString
pub fn compat_mode(&self) -> JsString
Getter of the compatMode attribute.
Document.compatMode
Sourcepub fn character_set(&self) -> JsString
pub fn character_set(&self) -> JsString
Getter of the characterSet attribute.
Document.characterSet
Sourcepub fn charset(&self) -> JsString
pub fn charset(&self) -> JsString
Getter of the charset attribute.
Document.charset
Sourcepub fn input_encoding(&self) -> JsString
pub fn input_encoding(&self) -> JsString
Getter of the inputEncoding attribute.
Document.inputEncoding
Sourcepub fn content_type(&self) -> JsString
pub fn content_type(&self) -> JsString
Getter of the contentType attribute.
Document.contentType
Sourcepub fn doctype(&self) -> DocumentType
pub fn doctype(&self) -> DocumentType
Getter of the doctype attribute.
Document.doctype
Sourcepub fn document_element(&self) -> Element
pub fn document_element(&self) -> Element
Getter of the documentElement attribute.
Document.documentElement
Sourcepub fn root_element(&self) -> SVGSVGElement
pub fn root_element(&self) -> SVGSVGElement
Getter of the rootElement attribute.
Document.rootElement
Sourcepub fn named_flows(&self) -> NamedFlowMap
pub fn named_flows(&self) -> NamedFlowMap
Getter of the namedFlows attribute.
Document.namedFlows
Sourcepub fn active_view_transition(&self) -> ViewTransition
pub fn active_view_transition(&self) -> ViewTransition
Getter of the activeViewTransition attribute.
Document.activeViewTransition
Sourcepub fn scrolling_element(&self) -> Element
pub fn scrolling_element(&self) -> Element
Getter of the scrollingElement attribute.
Document.scrollingElement
Sourcepub fn fullscreen_enabled(&self) -> bool
pub fn fullscreen_enabled(&self) -> bool
Getter of the fullscreenEnabled attribute.
Document.fullscreenEnabled
Sourcepub fn fullscreen(&self) -> bool
pub fn fullscreen(&self) -> bool
Getter of the fullscreen attribute.
Document.fullscreen
Sourcepub fn onfullscreenchange(&self) -> Any
pub fn onfullscreenchange(&self) -> Any
Getter of the onfullscreenchange attribute.
Document.onfullscreenchange
Sourcepub fn set_onfullscreenchange(&mut self, value: &Any)
pub fn set_onfullscreenchange(&mut self, value: &Any)
Setter of the onfullscreenchange attribute.
Document.onfullscreenchange
Sourcepub fn onfullscreenerror(&self) -> Any
pub fn onfullscreenerror(&self) -> Any
Getter of the onfullscreenerror attribute.
Document.onfullscreenerror
Sourcepub fn set_onfullscreenerror(&mut self, value: &Any)
pub fn set_onfullscreenerror(&mut self, value: &Any)
Setter of the onfullscreenerror attribute.
Document.onfullscreenerror
Sourcepub fn location(&self) -> Location
pub fn location(&self) -> Location
Getter of the location attribute.
Document.location
Sourcepub fn domain(&self) -> JsString
pub fn domain(&self) -> JsString
Getter of the domain attribute.
Document.domain
Sourcepub fn set_domain(&mut self, value: &JsString)
pub fn set_domain(&mut self, value: &JsString)
Setter of the domain attribute.
Document.domain
Sourcepub fn referrer(&self) -> JsString
pub fn referrer(&self) -> JsString
Getter of the referrer attribute.
Document.referrer
Getter of the cookie attribute.
Document.cookie
Setter of the cookie attribute.
Document.cookie
Sourcepub fn last_modified(&self) -> JsString
pub fn last_modified(&self) -> JsString
Getter of the lastModified attribute.
Document.lastModified
Sourcepub fn ready_state(&self) -> DocumentReadyState
pub fn ready_state(&self) -> DocumentReadyState
Getter of the readyState attribute.
Document.readyState
Sourcepub fn title(&self) -> JsString
pub fn title(&self) -> JsString
Getter of the title attribute.
Document.title
Sourcepub fn set_title(&mut self, value: &JsString)
pub fn set_title(&mut self, value: &JsString)
Setter of the title attribute.
Document.title
Sourcepub fn dir(&self) -> JsString
pub fn dir(&self) -> JsString
Getter of the dir attribute.
Document.dir
Sourcepub fn set_dir(&mut self, value: &JsString)
pub fn set_dir(&mut self, value: &JsString)
Setter of the dir attribute.
Document.dir
Sourcepub fn body(&self) -> HTMLElement
pub fn body(&self) -> HTMLElement
Getter of the body attribute.
Document.body
Sourcepub fn set_body(&mut self, value: &HTMLElement)
pub fn set_body(&mut self, value: &HTMLElement)
Setter of the body attribute.
Document.body
Sourcepub fn head(&self) -> HTMLHeadElement
pub fn head(&self) -> HTMLHeadElement
Getter of the head attribute.
Document.head
Sourcepub fn images(&self) -> HTMLCollection
pub fn images(&self) -> HTMLCollection
Getter of the images attribute.
Document.images
Sourcepub fn embeds(&self) -> HTMLCollection
pub fn embeds(&self) -> HTMLCollection
Getter of the embeds attribute.
Document.embeds
Sourcepub fn plugins(&self) -> HTMLCollection
pub fn plugins(&self) -> HTMLCollection
Getter of the plugins attribute.
Document.plugins
Sourcepub fn links(&self) -> HTMLCollection
pub fn links(&self) -> HTMLCollection
Getter of the links attribute.
Document.links
Sourcepub fn forms(&self) -> HTMLCollection
pub fn forms(&self) -> HTMLCollection
Getter of the forms attribute.
Document.forms
Sourcepub fn scripts(&self) -> HTMLCollection
pub fn scripts(&self) -> HTMLCollection
Getter of the scripts attribute.
Document.scripts
Sourcepub fn current_script(&self) -> Any
pub fn current_script(&self) -> Any
Getter of the currentScript attribute.
Document.currentScript
Sourcepub fn default_view(&self) -> Any
pub fn default_view(&self) -> Any
Getter of the defaultView attribute.
Document.defaultView
Sourcepub fn design_mode(&self) -> JsString
pub fn design_mode(&self) -> JsString
Getter of the designMode attribute.
Document.designMode
Sourcepub fn set_design_mode(&mut self, value: &JsString)
pub fn set_design_mode(&mut self, value: &JsString)
Setter of the designMode attribute.
Document.designMode
Getter of the hidden attribute.
Document.hidden
Sourcepub fn visibility_state(&self) -> DocumentVisibilityState
pub fn visibility_state(&self) -> DocumentVisibilityState
Getter of the visibilityState attribute.
Document.visibilityState
Sourcepub fn onreadystatechange(&self) -> Any
pub fn onreadystatechange(&self) -> Any
Getter of the onreadystatechange attribute.
Document.onreadystatechange
Sourcepub fn set_onreadystatechange(&mut self, value: &Any)
pub fn set_onreadystatechange(&mut self, value: &Any)
Setter of the onreadystatechange attribute.
Document.onreadystatechange
Sourcepub fn onvisibilitychange(&self) -> Any
pub fn onvisibilitychange(&self) -> Any
Getter of the onvisibilitychange attribute.
Document.onvisibilitychange
Sourcepub fn set_onvisibilitychange(&mut self, value: &Any)
pub fn set_onvisibilitychange(&mut self, value: &Any)
Setter of the onvisibilitychange attribute.
Document.onvisibilitychange
Sourcepub fn fg_color(&self) -> JsString
pub fn fg_color(&self) -> JsString
Getter of the fgColor attribute.
Document.fgColor
Sourcepub fn set_fg_color(&mut self, value: &JsString)
pub fn set_fg_color(&mut self, value: &JsString)
Setter of the fgColor attribute.
Document.fgColor
Sourcepub fn link_color(&self) -> JsString
pub fn link_color(&self) -> JsString
Getter of the linkColor attribute.
Document.linkColor
Sourcepub fn set_link_color(&mut self, value: &JsString)
pub fn set_link_color(&mut self, value: &JsString)
Setter of the linkColor attribute.
Document.linkColor
Sourcepub fn vlink_color(&self) -> JsString
pub fn vlink_color(&self) -> JsString
Getter of the vlinkColor attribute.
Document.vlinkColor
Sourcepub fn set_vlink_color(&mut self, value: &JsString)
pub fn set_vlink_color(&mut self, value: &JsString)
Setter of the vlinkColor attribute.
Document.vlinkColor
Sourcepub fn alink_color(&self) -> JsString
pub fn alink_color(&self) -> JsString
Getter of the alinkColor attribute.
Document.alinkColor
Sourcepub fn set_alink_color(&mut self, value: &JsString)
pub fn set_alink_color(&mut self, value: &JsString)
Setter of the alinkColor attribute.
Document.alinkColor
Sourcepub fn bg_color(&self) -> JsString
pub fn bg_color(&self) -> JsString
Getter of the bgColor attribute.
Document.bgColor
Sourcepub fn set_bg_color(&mut self, value: &JsString)
pub fn set_bg_color(&mut self, value: &JsString)
Setter of the bgColor attribute.
Document.bgColor
Sourcepub fn anchors(&self) -> HTMLCollection
pub fn anchors(&self) -> HTMLCollection
Getter of the anchors attribute.
Document.anchors
Sourcepub fn applets(&self) -> HTMLCollection
pub fn applets(&self) -> HTMLCollection
Getter of the applets attribute.
Document.applets
Sourcepub fn all(&self) -> HTMLAllCollection
pub fn all(&self) -> HTMLAllCollection
Getter of the all attribute.
Document.all
Sourcepub fn onfreeze(&self) -> Any
pub fn onfreeze(&self) -> Any
Getter of the onfreeze attribute.
Document.onfreeze
Sourcepub fn set_onfreeze(&mut self, value: &Any)
pub fn set_onfreeze(&mut self, value: &Any)
Setter of the onfreeze attribute.
Document.onfreeze
Sourcepub fn onresume(&self) -> Any
pub fn onresume(&self) -> Any
Getter of the onresume attribute.
Document.onresume
Sourcepub fn set_onresume(&mut self, value: &Any)
pub fn set_onresume(&mut self, value: &Any)
Setter of the onresume attribute.
Document.onresume
Sourcepub fn was_discarded(&self) -> bool
pub fn was_discarded(&self) -> bool
Getter of the wasDiscarded attribute.
Document.wasDiscarded
Sourcepub fn permissions_policy(&self) -> PermissionsPolicy
pub fn permissions_policy(&self) -> PermissionsPolicy
Getter of the permissionsPolicy attribute.
Document.permissionsPolicy
Sourcepub fn picture_in_picture_enabled(&self) -> bool
pub fn picture_in_picture_enabled(&self) -> bool
Getter of the pictureInPictureEnabled attribute.
Document.pictureInPictureEnabled
Sourcepub fn onpointerlockchange(&self) -> Any
pub fn onpointerlockchange(&self) -> Any
Getter of the onpointerlockchange attribute.
Document.onpointerlockchange
Sourcepub fn set_onpointerlockchange(&mut self, value: &Any)
pub fn set_onpointerlockchange(&mut self, value: &Any)
Setter of the onpointerlockchange attribute.
Document.onpointerlockchange
Sourcepub fn onpointerlockerror(&self) -> Any
pub fn onpointerlockerror(&self) -> Any
Getter of the onpointerlockerror attribute.
Document.onpointerlockerror
Sourcepub fn set_onpointerlockerror(&mut self, value: &Any)
pub fn set_onpointerlockerror(&mut self, value: &Any)
Setter of the onpointerlockerror attribute.
Document.onpointerlockerror
Sourcepub fn prerendering(&self) -> bool
pub fn prerendering(&self) -> bool
Getter of the prerendering attribute.
Document.prerendering
Sourcepub fn onprerenderingchange(&self) -> Any
pub fn onprerenderingchange(&self) -> Any
Getter of the onprerenderingchange attribute.
Document.onprerenderingchange
Sourcepub fn set_onprerenderingchange(&mut self, value: &Any)
pub fn set_onprerenderingchange(&mut self, value: &Any)
Setter of the onprerenderingchange attribute.
Document.onprerenderingchange
Sourcepub fn fragment_directive(&self) -> FragmentDirective
pub fn fragment_directive(&self) -> FragmentDirective
Getter of the fragmentDirective attribute.
Document.fragmentDirective
Sourcepub fn timeline(&self) -> DocumentTimeline
pub fn timeline(&self) -> DocumentTimeline
Getter of the timeline attribute.
Document.timeline
Sourcepub fn fonts(&self) -> FontFaceSet
pub fn fonts(&self) -> FontFaceSet
Getter of the fonts attribute.
Document.fonts
Sourcepub fn children(&self) -> HTMLCollection
pub fn children(&self) -> HTMLCollection
Getter of the children attribute.
Document.children
Sourcepub fn first_element_child(&self) -> Element
pub fn first_element_child(&self) -> Element
Getter of the firstElementChild attribute.
Document.firstElementChild
Sourcepub fn last_element_child(&self) -> Element
pub fn last_element_child(&self) -> Element
Getter of the lastElementChild attribute.
Document.lastElementChild
Sourcepub fn child_element_count(&self) -> u32
pub fn child_element_count(&self) -> u32
Getter of the childElementCount attribute.
Document.childElementCount
Sourcepub fn onbeforexrselect(&self) -> Any
pub fn onbeforexrselect(&self) -> Any
Getter of the onbeforexrselect attribute.
Document.onbeforexrselect
Sourcepub fn set_onbeforexrselect(&mut self, value: &Any)
pub fn set_onbeforexrselect(&mut self, value: &Any)
Setter of the onbeforexrselect attribute.
Document.onbeforexrselect
Sourcepub fn get_elements_by_tag_name(
&self,
qualified_name: &JsString,
) -> HTMLCollection
pub fn get_elements_by_tag_name( &self, qualified_name: &JsString, ) -> HTMLCollection
The getElementsByTagName method.
Document.getElementsByTagName
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn get_elements_by_tag_name_ns(
&self,
namespace: &JsString,
local_name: &JsString,
) -> HTMLCollection
pub fn get_elements_by_tag_name_ns( &self, namespace: &JsString, local_name: &JsString, ) -> HTMLCollection
The getElementsByTagNameNS method.
Document.getElementsByTagNameNS
Sourcepub fn get_elements_by_class_name(
&self,
class_names: &JsString,
) -> HTMLCollection
pub fn get_elements_by_class_name( &self, class_names: &JsString, ) -> HTMLCollection
The getElementsByClassName method.
Document.getElementsByClassName
Sourcepub fn create_element(&self, local_name: &JsString) -> Element
pub fn create_element(&self, local_name: &JsString) -> Element
The createElement method.
Document.createElement
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn create_element_with_options(
&self,
local_name: &JsString,
options: &Any,
) -> Element
pub fn create_element_with_options( &self, local_name: &JsString, options: &Any, ) -> Element
The createElement method.
Document.createElement
Sourcepub fn create_element_ns(
&self,
namespace: &JsString,
qualified_name: &JsString,
) -> Element
pub fn create_element_ns( &self, namespace: &JsString, qualified_name: &JsString, ) -> Element
The createElementNS method.
Document.createElementNS
Sourcepub fn create_element_ns_with_options(
&self,
namespace: &JsString,
qualified_name: &JsString,
options: &Any,
) -> Element
pub fn create_element_ns_with_options( &self, namespace: &JsString, qualified_name: &JsString, options: &Any, ) -> Element
The createElementNS method.
Document.createElementNS
Sourcepub fn create_document_fragment(&self) -> DocumentFragment
pub fn create_document_fragment(&self) -> DocumentFragment
The createDocumentFragment method.
Document.createDocumentFragment
Sourcepub fn create_text_node(&self, data: &JsString) -> Text
pub fn create_text_node(&self, data: &JsString) -> Text
The createTextNode method.
Document.createTextNode
Sourcepub fn create_cdata_section(&self, data: &JsString) -> CDATASection
pub fn create_cdata_section(&self, data: &JsString) -> CDATASection
The createCDATASection method.
Document.createCDATASection
Sourcepub fn create_comment(&self, data: &JsString) -> Comment
pub fn create_comment(&self, data: &JsString) -> Comment
The createComment method.
Document.createComment
Sourcepub fn create_processing_instruction(
&self,
target: &JsString,
data: &JsString,
) -> ProcessingInstruction
pub fn create_processing_instruction( &self, target: &JsString, data: &JsString, ) -> ProcessingInstruction
The createProcessingInstruction method.
Document.createProcessingInstruction
Sourcepub fn import_node(&self, node: &Node) -> Node
pub fn import_node(&self, node: &Node) -> Node
The importNode method.
Document.importNode
Sourcepub fn import_node_with_options(&self, node: &Node, options: &Any) -> Node
pub fn import_node_with_options(&self, node: &Node, options: &Any) -> Node
The importNode method.
Document.importNode
Sourcepub fn adopt_node(&self, node: &Node) -> Node
pub fn adopt_node(&self, node: &Node) -> Node
The adoptNode method.
Document.adoptNode
Sourcepub fn create_attribute(&self, local_name: &JsString) -> Attr
pub fn create_attribute(&self, local_name: &JsString) -> Attr
The createAttribute method.
Document.createAttribute
Sourcepub fn create_attribute_ns(
&self,
namespace: &JsString,
qualified_name: &JsString,
) -> Attr
pub fn create_attribute_ns( &self, namespace: &JsString, qualified_name: &JsString, ) -> Attr
The createAttributeNS method.
Document.createAttributeNS
Sourcepub fn create_event(&self, interface: &JsString) -> Event
pub fn create_event(&self, interface: &JsString) -> Event
The createEvent method.
Document.createEvent
Sourcepub fn create_range(&self) -> Range
pub fn create_range(&self) -> Range
The createRange method.
Document.createRange
Sourcepub fn create_node_iterator(&self, root: &Node) -> NodeIterator
pub fn create_node_iterator(&self, root: &Node) -> NodeIterator
The createNodeIterator method.
Document.createNodeIterator
Sourcepub fn create_node_iterator_with_what_to_show(
&self,
root: &Node,
what_to_show: u32,
) -> NodeIterator
pub fn create_node_iterator_with_what_to_show( &self, root: &Node, what_to_show: u32, ) -> NodeIterator
The createNodeIterator method.
Document.createNodeIterator
Sourcepub fn create_node_iterator_with_what_to_show_and_filter(
&self,
root: &Node,
what_to_show: u32,
filter: &NodeFilter,
) -> NodeIterator
pub fn create_node_iterator_with_what_to_show_and_filter( &self, root: &Node, what_to_show: u32, filter: &NodeFilter, ) -> NodeIterator
The createNodeIterator method.
Document.createNodeIterator
Sourcepub fn create_tree_walker(&self, root: &Node) -> TreeWalker
pub fn create_tree_walker(&self, root: &Node) -> TreeWalker
The createTreeWalker method.
Document.createTreeWalker
Sourcepub fn create_tree_walker_with_what_to_show(
&self,
root: &Node,
what_to_show: u32,
) -> TreeWalker
pub fn create_tree_walker_with_what_to_show( &self, root: &Node, what_to_show: u32, ) -> TreeWalker
The createTreeWalker method.
Document.createTreeWalker
Sourcepub fn create_tree_walker_with_what_to_show_and_filter(
&self,
root: &Node,
what_to_show: u32,
filter: &NodeFilter,
) -> TreeWalker
pub fn create_tree_walker_with_what_to_show_and_filter( &self, root: &Node, what_to_show: u32, filter: &NodeFilter, ) -> TreeWalker
The createTreeWalker method.
Document.createTreeWalker
Sourcepub fn start_view_transition(&self) -> ViewTransition
pub fn start_view_transition(&self) -> ViewTransition
The startViewTransition method.
Document.startViewTransition
Sourcepub fn start_view_transition_with_callback_options(
&self,
callback_options: &Any,
) -> ViewTransition
pub fn start_view_transition_with_callback_options( &self, callback_options: &Any, ) -> ViewTransition
The startViewTransition method.
Document.startViewTransition
Sourcepub fn element_from_point(&self, x: f64, y: f64) -> Element
pub fn element_from_point(&self, x: f64, y: f64) -> Element
The elementFromPoint method.
Document.elementFromPoint
Sourcepub fn elements_from_point(&self, x: f64, y: f64) -> TypedArray<Element>
pub fn elements_from_point(&self, x: f64, y: f64) -> TypedArray<Element>
The elementsFromPoint method.
Document.elementsFromPoint
Sourcepub fn caret_position_from_point(&self, x: f64, y: f64) -> CaretPosition
pub fn caret_position_from_point(&self, x: f64, y: f64) -> CaretPosition
The caretPositionFromPoint method.
Document.caretPositionFromPoint
Sourcepub fn caret_position_from_point_with_options(
&self,
x: f64,
y: f64,
options: &CaretPositionFromPointOptions,
) -> CaretPosition
pub fn caret_position_from_point_with_options( &self, x: f64, y: f64, options: &CaretPositionFromPointOptions, ) -> CaretPosition
The caretPositionFromPoint method.
Document.caretPositionFromPoint
Sourcepub fn measure_element(&self, element: &Element) -> FontMetrics
pub fn measure_element(&self, element: &Element) -> FontMetrics
The measureElement method.
Document.measureElement
Sourcepub fn measure_text(
&self,
text: &JsString,
style_map: &StylePropertyMapReadOnly,
) -> FontMetrics
pub fn measure_text( &self, text: &JsString, style_map: &StylePropertyMapReadOnly, ) -> FontMetrics
The measureText method.
Document.measureText
Sourcepub fn exit_fullscreen(&self) -> Promise<Undefined>
pub fn exit_fullscreen(&self) -> Promise<Undefined>
The exitFullscreen method.
Document.exitFullscreen
Sourcepub fn get_elements_by_name(&self, element_name: &JsString) -> NodeList
pub fn get_elements_by_name(&self, element_name: &JsString) -> NodeList
The getElementsByName method.
Document.getElementsByName
Sourcepub fn open(&self) -> Document
pub fn open(&self) -> Document
The open method.
Document.open
Sourcepub fn open_with_unused1(&self, unused1: &JsString) -> Document
pub fn open_with_unused1(&self, unused1: &JsString) -> Document
The open method.
Document.open
Sourcepub fn open_with_unused1_and_unused2(
&self,
unused1: &JsString,
unused2: &JsString,
) -> Document
pub fn open_with_unused1_and_unused2( &self, unused1: &JsString, unused2: &JsString, ) -> Document
The open method.
Document.open
Sourcepub fn open_with_url_and_name_and_features(
&self,
url: &JsString,
name: &JsString,
features: &JsString,
) -> Any
pub fn open_with_url_and_name_and_features( &self, url: &JsString, name: &JsString, features: &JsString, ) -> Any
The open method.
Document.open
Sourcepub fn close(&self) -> Undefined
pub fn close(&self) -> Undefined
The close method.
Document.close
Sourcepub fn write(&self, text: &Any) -> Undefined
pub fn write(&self, text: &Any) -> Undefined
The write method.
Document.write
Sourcepub fn writeln(&self, text: &Any) -> Undefined
pub fn writeln(&self, text: &Any) -> Undefined
The writeln method.
Document.writeln
Sourcepub fn has_focus(&self) -> bool
pub fn has_focus(&self) -> bool
The hasFocus method.
Document.hasFocus
Sourcepub fn exec_command(&self, command_id: &JsString) -> bool
pub fn exec_command(&self, command_id: &JsString) -> bool
The execCommand method.
Document.execCommand
Sourcepub fn exec_command_with_show_ui(
&self,
command_id: &JsString,
show_ui: bool,
) -> bool
pub fn exec_command_with_show_ui( &self, command_id: &JsString, show_ui: bool, ) -> bool
The execCommand method.
Document.execCommand
Sourcepub fn exec_command_with_show_ui_and_value(
&self,
command_id: &JsString,
show_ui: bool,
value: &JsString,
) -> bool
pub fn exec_command_with_show_ui_and_value( &self, command_id: &JsString, show_ui: bool, value: &JsString, ) -> bool
The execCommand method.
Document.execCommand
Sourcepub fn query_command_enabled(&self, command_id: &JsString) -> bool
pub fn query_command_enabled(&self, command_id: &JsString) -> bool
The queryCommandEnabled method.
Document.queryCommandEnabled
Sourcepub fn query_command_indeterm(&self, command_id: &JsString) -> bool
pub fn query_command_indeterm(&self, command_id: &JsString) -> bool
The queryCommandIndeterm method.
Document.queryCommandIndeterm
Sourcepub fn query_command_state(&self, command_id: &JsString) -> bool
pub fn query_command_state(&self, command_id: &JsString) -> bool
The queryCommandState method.
Document.queryCommandState
Sourcepub fn query_command_supported(&self, command_id: &JsString) -> bool
pub fn query_command_supported(&self, command_id: &JsString) -> bool
The queryCommandSupported method.
Document.queryCommandSupported
Sourcepub fn query_command_value(&self, command_id: &JsString) -> JsString
pub fn query_command_value(&self, command_id: &JsString) -> JsString
The queryCommandValue method.
Document.queryCommandValue
Sourcepub fn clear(&self) -> Undefined
pub fn clear(&self) -> Undefined
The clear method.
Document.clear
Sourcepub fn capture_events(&self) -> Undefined
pub fn capture_events(&self) -> Undefined
The captureEvents method.
Document.captureEvents
Sourcepub fn release_events(&self) -> Undefined
pub fn release_events(&self) -> Undefined
The releaseEvents method.
Document.releaseEvents
Sourcepub fn exit_picture_in_picture(&self) -> Promise<Undefined>
pub fn exit_picture_in_picture(&self) -> Promise<Undefined>
The exitPictureInPicture method.
Document.exitPictureInPicture
Sourcepub fn exit_pointer_lock(&self) -> Undefined
pub fn exit_pointer_lock(&self) -> Undefined
The exitPointerLock method.
Document.exitPointerLock
Sourcepub fn request_storage_access_for(
&self,
requested_origin: &JsString,
) -> Promise<Undefined>
pub fn request_storage_access_for( &self, requested_origin: &JsString, ) -> Promise<Undefined>
The requestStorageAccessFor method.
Document.requestStorageAccessFor
The hasUnpartitionedCookieAccess method.
Document.hasUnpartitionedCookieAccess
Sourcepub fn get_selection(&self) -> Selection
pub fn get_selection(&self) -> Selection
The getSelection method.
Document.getSelection
Sourcepub fn has_storage_access(&self) -> Promise<bool>
pub fn has_storage_access(&self) -> Promise<bool>
The hasStorageAccess method.
Document.hasStorageAccess
Sourcepub fn request_storage_access(&self) -> Promise<Undefined>
pub fn request_storage_access(&self) -> Promise<Undefined>
The requestStorageAccess method.
Document.requestStorageAccess
Sourcepub fn has_private_token(&self, issuer: &JsString) -> Promise<bool>
pub fn has_private_token(&self, issuer: &JsString) -> Promise<bool>
The hasPrivateToken method.
Document.hasPrivateToken
Sourcepub fn has_redemption_record(&self, issuer: &JsString) -> Promise<bool>
pub fn has_redemption_record(&self, issuer: &JsString) -> Promise<bool>
The hasRedemptionRecord method.
Document.hasRedemptionRecord
Sourcepub fn get_box_quads(&self) -> TypedArray<DOMQuad>
pub fn get_box_quads(&self) -> TypedArray<DOMQuad>
The getBoxQuads method.
Document.getBoxQuads
Sourcepub fn get_box_quads_with_options(
&self,
options: &BoxQuadOptions,
) -> TypedArray<DOMQuad>
pub fn get_box_quads_with_options( &self, options: &BoxQuadOptions, ) -> TypedArray<DOMQuad>
The getBoxQuads method.
Document.getBoxQuads
Sourcepub fn convert_quad_from_node(&self, quad: &DOMQuadInit, from: &Any) -> DOMQuad
pub fn convert_quad_from_node(&self, quad: &DOMQuadInit, from: &Any) -> DOMQuad
The convertQuadFromNode method.
Document.convertQuadFromNode
Sourcepub fn convert_quad_from_node_with_options(
&self,
quad: &DOMQuadInit,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMQuad
pub fn convert_quad_from_node_with_options( &self, quad: &DOMQuadInit, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMQuad
The convertQuadFromNode method.
Document.convertQuadFromNode
Sourcepub fn convert_rect_from_node(
&self,
rect: &DOMRectReadOnly,
from: &Any,
) -> DOMQuad
pub fn convert_rect_from_node( &self, rect: &DOMRectReadOnly, from: &Any, ) -> DOMQuad
The convertRectFromNode method.
Document.convertRectFromNode
Sourcepub fn convert_rect_from_node_with_options(
&self,
rect: &DOMRectReadOnly,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMQuad
pub fn convert_rect_from_node_with_options( &self, rect: &DOMRectReadOnly, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMQuad
The convertRectFromNode method.
Document.convertRectFromNode
Sourcepub fn convert_point_from_node(
&self,
point: &DOMPointInit,
from: &Any,
) -> DOMPoint
pub fn convert_point_from_node( &self, point: &DOMPointInit, from: &Any, ) -> DOMPoint
The convertPointFromNode method.
Document.convertPointFromNode
Sourcepub fn convert_point_from_node_with_options(
&self,
point: &DOMPointInit,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMPoint
pub fn convert_point_from_node_with_options( &self, point: &DOMPointInit, from: &Any, options: &ConvertCoordinateOptions, ) -> DOMPoint
The convertPointFromNode method.
Document.convertPointFromNode
Sourcepub fn get_element_by_id(&self, element_id: &JsString) -> Element
pub fn get_element_by_id(&self, element_id: &JsString) -> Element
The getElementById method.
Document.getElementById
Sourcepub fn get_animations(&self) -> TypedArray<Animation>
pub fn get_animations(&self) -> TypedArray<Animation>
The getAnimations method.
Document.getAnimations
Sourcepub fn prepend(&self, nodes: &Any) -> Undefined
pub fn prepend(&self, nodes: &Any) -> Undefined
The prepend method.
Document.prepend
Sourcepub fn append(&self, nodes: &Any) -> Undefined
pub fn append(&self, nodes: &Any) -> Undefined
The append method.
Document.append
Sourcepub fn replace_children(&self, nodes: &Any) -> Undefined
pub fn replace_children(&self, nodes: &Any) -> Undefined
The replaceChildren method.
Document.replaceChildren
Sourcepub fn move_before(&self, node: &Node, child: &Node) -> Undefined
pub fn move_before(&self, node: &Node, child: &Node) -> Undefined
The moveBefore method.
Document.moveBefore
Sourcepub fn query_selector(&self, selectors: &JsString) -> Element
pub fn query_selector(&self, selectors: &JsString) -> Element
The querySelector method.
Document.querySelector
Sourcepub fn query_selector_all(&self, selectors: &JsString) -> NodeList
pub fn query_selector_all(&self, selectors: &JsString) -> NodeList
The querySelectorAll method.
Document.querySelectorAll
Sourcepub fn create_expression(&self, expression: &JsString) -> XPathExpression
pub fn create_expression(&self, expression: &JsString) -> XPathExpression
The createExpression method.
Document.createExpression
Sourcepub fn create_expression_with_resolver(
&self,
expression: &JsString,
resolver: &XPathNSResolver,
) -> XPathExpression
pub fn create_expression_with_resolver( &self, expression: &JsString, resolver: &XPathNSResolver, ) -> XPathExpression
The createExpression method.
Document.createExpression
Sourcepub fn create_ns_resolver(&self, node_resolver: &Node) -> Node
pub fn create_ns_resolver(&self, node_resolver: &Node) -> Node
The createNSResolver method.
Document.createNSResolver
Sourcepub fn evaluate(
&self,
expression: &JsString,
context_node: &Node,
) -> XPathResult
pub fn evaluate( &self, expression: &JsString, context_node: &Node, ) -> XPathResult
The evaluate method.
Document.evaluate
Sourcepub fn evaluate_with_resolver(
&self,
expression: &JsString,
context_node: &Node,
resolver: &XPathNSResolver,
) -> XPathResult
pub fn evaluate_with_resolver( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, ) -> XPathResult
The evaluate method.
Document.evaluate
Sourcepub fn evaluate_with_resolver_and_type(
&self,
expression: &JsString,
context_node: &Node,
resolver: &XPathNSResolver,
type_: u16,
) -> XPathResult
pub fn evaluate_with_resolver_and_type( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, type_: u16, ) -> XPathResult
The evaluate method.
Document.evaluate
Sourcepub fn evaluate_with_resolver_and_type_and_result(
&self,
expression: &JsString,
context_node: &Node,
resolver: &XPathNSResolver,
type_: u16,
result: &XPathResult,
) -> XPathResult
pub fn evaluate_with_resolver_and_type_and_result( &self, expression: &JsString, context_node: &Node, resolver: &XPathNSResolver, type_: u16, result: &XPathResult, ) -> XPathResult
The evaluate method.
Document.evaluate
Methods from Deref<Target = Node>§
Sourcepub fn node_type(&self) -> u16
pub fn node_type(&self) -> u16
Getter of the nodeType attribute.
Node.nodeType
Sourcepub fn node_name(&self) -> JsString
pub fn node_name(&self) -> JsString
Getter of the nodeName attribute.
Node.nodeName
Sourcepub fn base_uri(&self) -> JsString
pub fn base_uri(&self) -> JsString
Getter of the baseURI attribute.
Node.baseURI
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Getter of the isConnected attribute.
Node.isConnected
Sourcepub fn owner_document(&self) -> Document
pub fn owner_document(&self) -> Document
Getter of the ownerDocument attribute.
Node.ownerDocument
Sourcepub fn parent_node(&self) -> Node
pub fn parent_node(&self) -> Node
Getter of the parentNode attribute.
Node.parentNode
Sourcepub fn parent_element(&self) -> Element
pub fn parent_element(&self) -> Element
Getter of the parentElement attribute.
Node.parentElement
Sourcepub fn child_nodes(&self) -> NodeList
pub fn child_nodes(&self) -> NodeList
Getter of the childNodes attribute.
Node.childNodes
Sourcepub fn first_child(&self) -> Node
pub fn first_child(&self) -> Node
Getter of the firstChild attribute.
Node.firstChild
Sourcepub fn last_child(&self) -> Node
pub fn last_child(&self) -> Node
Getter of the lastChild attribute.
Node.lastChild
Sourcepub fn previous_sibling(&self) -> Node
pub fn previous_sibling(&self) -> Node
Getter of the previousSibling attribute.
Node.previousSibling
Sourcepub fn next_sibling(&self) -> Node
pub fn next_sibling(&self) -> Node
Getter of the nextSibling attribute.
Node.nextSibling
Sourcepub fn node_value(&self) -> JsString
pub fn node_value(&self) -> JsString
Getter of the nodeValue attribute.
Node.nodeValue
Sourcepub fn set_node_value(&mut self, value: &JsString)
pub fn set_node_value(&mut self, value: &JsString)
Setter of the nodeValue attribute.
Node.nodeValue
Sourcepub fn text_content(&self) -> JsString
pub fn text_content(&self) -> JsString
Getter of the textContent attribute.
Node.textContent
Sourcepub fn set_text_content(&mut self, value: &JsString)
pub fn set_text_content(&mut self, value: &JsString)
Setter of the textContent attribute.
Node.textContent
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn get_root_node(&self) -> Node
pub fn get_root_node(&self) -> Node
The getRootNode method.
Node.getRootNode
Sourcepub fn get_root_node_with_options(&self, options: &GetRootNodeOptions) -> Node
pub fn get_root_node_with_options(&self, options: &GetRootNodeOptions) -> Node
The getRootNode method.
Node.getRootNode
Sourcepub fn has_child_nodes(&self) -> bool
pub fn has_child_nodes(&self) -> bool
The hasChildNodes method.
Node.hasChildNodes
Sourcepub fn normalize(&self) -> Undefined
pub fn normalize(&self) -> Undefined
The normalize method.
Node.normalize
Sourcepub fn clone_node(&self) -> Node
pub fn clone_node(&self) -> Node
The cloneNode method.
Node.cloneNode
Sourcepub fn clone_node_with_subtree(&self, subtree: bool) -> Node
pub fn clone_node_with_subtree(&self, subtree: bool) -> Node
The cloneNode method.
Node.cloneNode
Sourcepub fn is_equal_node(&self, other_node: &Node) -> bool
pub fn is_equal_node(&self, other_node: &Node) -> bool
The isEqualNode method.
Node.isEqualNode
Sourcepub fn is_same_node(&self, other_node: &Node) -> bool
pub fn is_same_node(&self, other_node: &Node) -> bool
The isSameNode method.
Node.isSameNode
Sourcepub fn compare_document_position(&self, other: &Node) -> u16
pub fn compare_document_position(&self, other: &Node) -> u16
The compareDocumentPosition method.
Node.compareDocumentPosition
Sourcepub fn contains(&self, other: &Node) -> bool
pub fn contains(&self, other: &Node) -> bool
The contains method.
Node.contains
Sourcepub fn lookup_prefix(&self, namespace: &JsString) -> JsString
pub fn lookup_prefix(&self, namespace: &JsString) -> JsString
The lookupPrefix method.
Node.lookupPrefix
Sourcepub fn lookup_namespace_uri(&self, prefix: &JsString) -> JsString
pub fn lookup_namespace_uri(&self, prefix: &JsString) -> JsString
The lookupNamespaceURI method.
Node.lookupNamespaceURI
Sourcepub fn is_default_namespace(&self, namespace: &JsString) -> bool
pub fn is_default_namespace(&self, namespace: &JsString) -> bool
The isDefaultNamespace method.
Node.isDefaultNamespace
Sourcepub fn insert_before(&self, node: &Node, child: &Node) -> Node
pub fn insert_before(&self, node: &Node, child: &Node) -> Node
The insertBefore method.
Node.insertBefore
Sourcepub fn append_child(&self, node: &Node) -> Node
pub fn append_child(&self, node: &Node) -> Node
The appendChild method.
Node.appendChild
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn replace_child(&self, node: &Node, child: &Node) -> Node
pub fn replace_child(&self, node: &Node, child: &Node) -> Node
The replaceChild method.
Node.replaceChild
Sourcepub fn remove_child(&self, child: &Node) -> Node
pub fn remove_child(&self, child: &Node) -> Node
The removeChild method.
Node.removeChild
Methods from Deref<Target = EventTarget>§
Sourcepub fn add_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn add_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn add_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn add_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Sourcepub fn remove_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn remove_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn remove_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn remove_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn dispatch_event(&self, event: &Event) -> bool
pub fn dispatch_event(&self, event: &Event) -> bool
The dispatchEvent method.
EventTarget.dispatchEvent
Sourcepub fn when(&self, type_: &JsString) -> Observable
pub fn when(&self, type_: &JsString) -> Observable
The when method.
EventTarget.when
Sourcepub fn when_with_options(
&self,
type_: &JsString,
options: &ObservableEventListenerOptions,
) -> Observable
pub fn when_with_options( &self, type_: &JsString, options: &ObservableEventListenerOptions, ) -> Observable
The when method.
EventTarget.when
Methods from Deref<Target = Any>§
Sourcepub fn has_own_property(&self, prop: &str) -> bool
pub fn has_own_property(&self, prop: &str) -> bool
Checks whether a non-inherited property prop exists
Sourcepub fn at<T>(&self, idx: T) -> Val
pub fn at<T>(&self, idx: T) -> Val
Gets the element at index idx. Assumes the underlying js type is indexable
Sourcepub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
pub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
Converts the underlying js array to a Vec of V
Sourcepub fn call(&self, f: &str, args: &[Val]) -> Val
pub fn call(&self, f: &str, args: &[Val]) -> Val
Calls the method f with args, can return an undefined js value
Sourcepub fn new(&self, args: &[Val]) -> Val
pub fn new(&self, args: &[Val]) -> Val
Calls the object’s constructor with args constructing a new object
Sourcepub fn invoke(&self, args: &[Val]) -> Val
pub fn invoke(&self, args: &[Val]) -> Val
Invokes the function object with args, can return an undefined js value
Sourcepub fn instanceof(&self, v: Val) -> bool
pub fn instanceof(&self, v: Val) -> bool
Checks whether this Val is an instanceof v
pub fn is_number(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_error(&self) -> bool
pub fn is_function(&self) -> bool
pub fn as_<T>(&self) -> Twhere
T: FromVal,
Trait Implementations§
Source§impl AsMut<Val> for XMLDocument
impl AsMut<Val> for XMLDocument
Source§impl AsRef<Val> for XMLDocument
impl AsRef<Val> for XMLDocument
Source§impl Clone for XMLDocument
impl Clone for XMLDocument
Source§fn clone(&self) -> XMLDocument
fn clone(&self) -> XMLDocument
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for XMLDocument
impl Debug for XMLDocument
Source§impl Deref for XMLDocument
impl Deref for XMLDocument
Source§impl DerefMut for XMLDocument
impl DerefMut for XMLDocument
Source§impl DynCast for XMLDocument
impl DynCast for XMLDocument
Source§fn instanceof(val: &Any) -> bool
fn instanceof(val: &Any) -> bool
val instanceof ThisType.Source§fn unchecked_from_val(v: Any) -> Self
fn unchecked_from_val(v: Any) -> Self
Val into Self.Source§fn unchecked_from_val_ref(v: &Any) -> &Self
fn unchecked_from_val_ref(v: &Any) -> &Self
&Val into &Self.Source§fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
&mut Val into &mut Self.fn has_type<T>(&self) -> boolwhere
T: DynCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: DynCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: DynCast,
fn dyn_mut<T>(&mut self) -> Option<&mut T>where
T: DynCast,
fn unchecked_into<T>(self) -> Twhere
T: DynCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: DynCast,
fn unchecked_mut<T>(&mut self) -> &mut Twhere
T: DynCast,
fn is_instance_of<T>(&self) -> boolwhere
T: DynCast,
Source§fn is_type_of(val: &Val) -> bool
fn is_type_of(val: &Val) -> bool
instanceof.