web_sys::Document::new function

Example

This example calls the window getter to access its document. The URL of the document is then logged to the console. Finally, the new function is called to create a new document. The new document can be associated with the contentDocument of a frame.


	pub fn document_new()
	{
		let window = web_sys::window().expect("global window does not exists");    
		let document = window.document().expect("expecting a document on window");
		web_sys::console::log_2(&"URL: %s".into(),
								&JsValue::from_str(&document.url().unwrap()));
		let new_document = Document::new().unwrap();	
	}

Function


	pub fn new() -> Result<Element, JsValue>

features/dependencies

Source Code