Document
Reference : https://developer.mozilla.org/en-US/docs/Web/API/Document/Document
document : provides html structure of page
syntax: document
Properties of document with samples:
1. document.location
Location {href: "https://en.wikipedia.org/wiki/Main_Page", ancestorOrigins: DOMStringList, origin: "https://en.wikipedia.org", protocol: "https:", host: "en.wikipedia.org", …}
2. document.alinkColor
document.alinkColor='blue';
"blue"
Deprecated
This feature is no longer recommended.
3.document.all
HTMLCollection [a, 8423465584828397121: a]
The anchors read-only property of the Document interface returns a list of all of the anchors in the document.
Deprecated
This feature is no longer recommended.
5. document.applets
HTMLCollection []
Deprecated
This feature is no longer recommended
6. document.bgColor
The deprecated bgColor property gets or sets the background color of the current document.
document.bgColor is deprecated in DOM Level 2 HTML.
Alternative - use of the CSS style background-color which can be accessed through the DOM with document.body.style.backgroundColor
7. document.body
The Document.body property represents the <body> or <frameset> node of the current document, or null if no such element exists.
8. document.characterSet
"UTF-8"
The properties document.charset and document.inputEncoding are legacy aliases for document.characterSet. Do not use them any more.
9. document.childElementCount
1
The ParentNode.childElementCount read-only property returns an unsigned long representing the number of child elements of the given element
Example:
var foo = document.getElementById('foo');
if (foo.childElementCount > 0) {
// Do something
}10. document.compatMode
"CSS1Compat"
Syntax
const mode = document.compatMode
Value
An enumerated value that can be:
"BackCompat"if the document is in quirks mode."CSS1Compat"if the document is in no-quirks (also known as "standards") mode or limited-quirks (also known as "almost standards") mode.
11. document.contentType
"text/html"
returns the MIME type that the document is being rendered as. This may come from HTTP headers or other sources of MIME information, and might be affected by automatic type conversions performed by either the browser or extensions.
12. document.designMode
"off"
controls whether the entire document is editable. Valid values are "on" and "off"
13. document.doctype
The returned object implements the DocumentType interface.
14. document.documentElement
Document.documentElement returns the Element that is the root element of the document (for example, the <html> element for HTML documents).
15. document.documentURI
The domain property of the Document interface gets/sets the domain portion of the origin of the current document
17. document.embeds
HTMLCollection []
The embeds read-only property of the Document interface returns a list of the embedded <object> elements within the current document.
18. document.firstElementChild
html
The ParentNode.firstElementChild read-only property returns the object's first child Element, or null if there are no child elements.
19. document.forms
The forms read-only property of the Document interface returns an HTMLCollection listing all the <form> elements contained in the document.
20. document.head
------>
--------------------------------------------------
Methods:
2. document.write
ƒ (){$(document.body).append($.parseHTML(Array.prototype.join.call(arguments,'')));}
document.write() writes to the document stream, calling document.write() on a closed (loaded) document automatically calls document.open(), which will clear the document.
If the document.write() call is embedded within an inline HTML <script> tag, then it will not call document.open(). For example:
<script>
document.write("<h1>Main title</h1>")
</script> Chrome will not execute <script> elements injected via document.write() when specific conditions are met. For more information, refer to Intervening against document.write().
Require arguments
Note: Use of "document.write" is deprecated. Use jQuery or mw.loader.load instead.
3. document.writeln
ƒ (){$(document.body).append($.parseHTML(Array.prototype.join.call(arguments,'')));}
Note: Use of "document.write" is deprecated. Use jQuery or mw.loader.load instead.
4. location.search
Returns url query parameters
i.e for url https://www.w3schools.com/js/tryit.asp?filename=tryjs_function_call_arguments
location.search will return '?filename=tryjs_function_call_arguments'
No comments:
Post a Comment