Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the properties and methods of Document objects

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to understand the attributes and methods of Document objects, for this problem, this article describes the corresponding analysis and solutions in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.

A document object model or DOM is an API that defines how to access the objects that make up a document. The W3C defines a standard DOM. Prior to this, when Netscape was the leading browser vendor, Netscape2 and Netscape3 supported a simple DOM that provided access only to special document elements such as links, images and forms.

This legacy DOM has been adopted by all browser vendors and has been formally incorporated into the W3C standard as a "Level 0"DOM. This legacy DOM is still valid in all browsers.

Why you need to know about "Level 0 DOM"

"Level 0 DOM" is obsolete, and the DOM standard defined by the W3C has a good way to achieve the same effect:

It exists and is still valid in all browsers. And sometimes he's easier to use.

2, more methods will cause confusion, if you don't want to be confused then understand it, clearly distinguish it.

a word

A "Level 0 DOM" is essentially a Document object defined with properties and methods.

Properties and methods of Document objects

First of all, the Document object can be obtained with window.document, because it is a property of the window object. You can write document directly because the window object is a global object.

method

[xss_clean]() Write HTML expressions or JavaScript code to documents.

[xss_clean]ln() is equivalent to the write() method, except that a newline is written after each expression.

document.open() Open the document to collect output from any [xss_clean]() or [xss_clean]ln() method.

document.close() Just like above you have to close the document after writing something, note that this is not window.close() This is two different things.

attribute

document.bgColor is actually the bgcolor attribute of the corresponding tag (no longer used).

[xss_clean] Sets or returns all cookies associated with the current document.

3. document. domainFor same-origin policy security restrictions, return the domain name of the current document.

document.lastModified A string containing the date the document was modified.

_document.location is equivalent to URL is no longer used.

document.referrer URL of a link that takes the browser to the current page.

document.title Returns the title of the current document.

document.URL Returns the URL of the current document.

Properties in array form

document.anchors[] A collection of anchors in a document.

document.applets[] A collection of applets in a document.

document.forms[] A collection of forms in a document.

document.images[] A collection of images in a document.

document.links[] Collection of links in documents Note that links include and.

summary

There are a few more things to remember about DOM Level 0:

"Level 0 DOM" has no way to change the document structure, only to add new tags to tags.

If there is one you can quote it for three formats. The first is: document.forms[0]. The second is: document.forms.f1. Three are: document.forms["f1"].

If two elements have the same name "n" then document.n becomes an array that holds references to both elements.

About how to understand the attributes and methods of Document object questions to share here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report