JavaScript:Document
lastmod 2023-02-19created 2020-10-145 edits
The Document interface represents a web page loaded in the browser and serves as the entry point to the page content (the DOM tree). The DOM tree includes elements such as
<body>
and
<table>along with many others. Document provides functionality globally, such as getting the page's URL or creating new elements in the document.
The Document interface describes the common properties and methods for any kind of document. Depending on the document's type (HTML, XML, SVG, etc.), a larger API is available. For example, HTML documents served with the "text/html" content type also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.
How to get browser URL properties
- Stackoverflow - Using $location.protocol() and $location.host() in Vuejs application
-
document.location.protocolfor protocol -
document.location.hostfor the current host - or just
document.location.originforprotocol+'://'+host
APIs
createElement
- Document.createElement() - Web API | MDN
- JavaScript / Adding elements / .createElement(), .createTextNode(), .appendChild() – CODING FACTORY
Creates a new element.
generates the following code.
The created element is added as a node using Node.appendChild() or Node.insertBefore().