document.all and WEB standards_Basic knowledge
WEB standards are really popular now, but what is discussed below is a document.all[] that does not meet the standards. DOM - DOCUMENT OBJECT MODEL document object model provides methods to access document objects. For example, if there is a table in the document and you want to change its background color, you can use document.all[] to access the TABLE in javascript. But the DOM is also different. Because of the competition between browser manufacturers, each browser manufacturer has developed its own private DOM, which can only run correctly on its own browser. document.all[] can only run on IE. Microsoft's private DOM. In order to correctly understand the DOM, the DOM of IE4 is given
2. Understand document.all[]
Starting from IE4, IE’s object model only added document.all[ ], let’s take a look at the Description of document.all[]:
Array of all HTML tags in the document.Collection of all elements contained by the object.
That is to say, document.all[] is a document An array variable composed of all tags in , including all elements in the document object (see Example 1).
IE's document.all collection exposes all document elements. This array provides access to every element in the document.
document.all[] This array provides access to all elements in the document.
Example 1 (this allows you to understand which objects are in the document)
[Ctrl A to select all Note: If you need to introduce external Js, you need to refresh to execute
ã Example 2 (Accessing a specific element)
If you need to introduce external Js, you need to refresh to execute
]
The above example lets you understand how to access a specific element in the document. For example, if there is a DIV in the document
, you can use this Access this DIV using the ID, NAME or INDEX attribute of the DIV:
document.all["docid"]
document.all["docname"]
document.all.item("docid")
document.all.item("docname")
ãã3ã使ç¨document.all[]
ä¾3
[Ctrl+A å ¨é æ³¨:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]
ãã4ãæ åDOMä¸çè®¿é®æ¹æ³
ããå¼å¤´å°±è¯´è¿document.all[]ä¸ç¬¦åWEBæ åï¼é£ç¨ä»ä¹æ¥æ¿ä»£å®å¢ï¼document.getElementById
Most third-party browsers are âstrict standardsâ implementations, meaning that they implement W3C and ECMA standards and ignore most of the proprietary object models of Internet Explorer and Netscape.If the demographic for your Web site includes users likely to use less common browsers, such as Linux aficionados, it might be a good idea to avoid IE-specific features and use the W3C DOM instead. by Internet Explorer 6, we see that IE implements significant portions of the W3C DOM.
ããè¿æ®µè¯çæææ¯å¤§å¤æ°ç¬¬ä¸æ¹æµè§å¨åªæ¯æW3CçDOMï¼å¦æä½ çç½ç«ç¨æ·ä½¿ç¨å ¶ä»çæµè§å¨ï¼é£ä¹ä½ æå¥½é¿å 使ç¨IEçç§æå±æ§ãèä¸IE6ä¹å¼å§æ¯æW3CãDOMã
ããæ¯ç«å¤§å¤æ°äººè¿ä¸äºè§£æ åï¼å¨ä½¿ç¨æ ååï¼ä½ è¿å¯ä»¥å¨ä½ çç½é¡µä¸ç¨document.all[]è®¿é®ææ¡£å¯¹è±¡åé¢åå°WEBæ åï¼ä»å¤©ç»§ç»WEBæ åä¸å¯ä»¥éè¿getElementById(), getElementsByName(), and getElementsByTagName()访é®DOCUMENTä¸çä»»ä¸ä¸ªæ ç¾ï¼
ãã1ãgetElementById()
ããgetElementById()å¯ä»¥è®¿é®DOCUMENTä¸çæä¸ç¹å®å ç´ ï¼é¡¾åæä¹ï¼å°±æ¯éè¿IDæ¥åå¾å ç´ ï¼æä»¥åªè½è®¿é®è®¾ç½®äºIDçå ç´ ã
ããæ¯å¦è¯´æä¸ä¸ªDIVçID为docidï¼
ããé£ä¹å°±å¯ä»¥ç¨getElementById("docid")æ¥è·å¾è¿ä¸ªå ç´ ã
[Ctrl+A å ¨é æ³¨:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]
ãã2ãgetElementsByName()
ããè¿ä¸ªæ¯éè¿NAMEæ¥è·å¾å ç´ ï¼ä½ä¸ç¥å¤§å®¶æ³¨ææ²¡æï¼è¿ä¸ªæ¯GETãELEMENTSï¼å¤æ°ELEMENTS代表è·å¾ç䏿¯ä¸ä¸ªå ç´ ï¼ä¸ºä»ä¹å¢ï¼
ããå 为DOCUMENT䏿¯ä¸ä¸ªå ç´ çIDæ¯å¯ä¸çï¼ä½NAMEå´å¯ä»¥éå¤ãæä¸ªæ¯å»å°±å人ç身份è¯å·æ¯å¯ä¸çï¼ç论ä¸ï¼è½ç¶ç°å®ä¸æéå¤ï¼ï¼ä½ååéå¤çå´å¾å¤ã妿ä¸ä¸ªææ¡£ä¸æä¸¤ä¸ªä»¥ä¸çæ ç¾NAMEç¸åï¼é£ä¹getElementsByName()å°±å¯ä»¥åå¾è¿äºå ç´ ç»æä¸ä¸ªæ°ç»ã
ããæ¯å¦æä¸¤ä¸ªDIVï¼
ããé£ä¹å¯ä»¥ç¨getElementsByName("docname")è·å¾è¿ä¸¤ä¸ªDIVï¼ç¨getElementsByName("docname")[0]访é®ç¬¬ä¸ä¸ªDIVï¼ç¨getElementsByName("docname")[1]访é®ç¬¬äºä¸ªDIVã
ããä¸é¢è¿æ®µè¯æéï¼è¯·çforforçåå¤ï¼ä½æ¯å¾å¯æï¼IEæ²¡ææ¯æè¿ä¸ªæ¹æ³ï¼å¤§å®¶æå ´è¶£å¯ä»¥å¨FIREFOXæNETSCAPEä¸è°è¯ä¸é¢è¿ä¸ªä¾åãï¼æå¨NETSCAPE7.2è±æçåFIREFOX1.0ä¸è°è¯æåãï¼
[Ctrl+A å ¨é æ³¨:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]
ããçæ¥ææ°çæµè§å¨çè§£WEBæ åè¿æ¯æé®é¢ï¼æç¥éçåªæçæ¨¡åãç©ºæ ¼BUGãæ¼æµ®BUGãFLASHæå ¥BUGï¼ä»document.getElementsByNameå¯ä»¥çåºFIREFOXï¼NETSCAPEçè§£æ åæåå·®ï¼ä½forfor说ç对ï¼è¦çµæ´»åºç¨æ åã
ãã3ãgetElementsByTagName()
ããè¿ä¸ªå¢å°±æ¯éè¿TAGNAMEï¼æ ç¾åç§°ï¼æ¥è·å¾å ç´ ï¼ä¸ä¸ªDOCUMENTä¸å½ç¶ä¼æç¸åçæ ç¾ï¼æä»¥è¿ä¸ªæ¹æ³ä¹æ¯åå¾ä¸ä¸ªæ°ç»ã
ããä¸é¢è¿ä¸ªä¾åæä¸¤ä¸ªDIVï¼å¯ä»¥ç¨getElementsByTagName("div")æ¥è®¿é®å®ä»¬ï¼ç¨getElementsByTagName("div")[0]访é®ç¬¬ä¸ä¸ªDIVï¼ç¨
getElementsByTagName("div")[1]访é®ç¬¬äºä¸ªDIVã
[Ctrl+A å ¨é æ³¨:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]
ããå ³äºdocument.getElementsByName
ããIEå½ç¶æ¯æ å¯ä»¥è¯´IEæ´å¿ äºhtml/xhtmlæ å(å¿å¿ 忥firefoxä¹ä¸åå° å¹¸ç¾ä¹ç¥¸ä¸ä¸^_^)
ããæç §O'REILLYç<>ä¸çè¯´æ³ name并䏿¯æ ¸å¿å±æ§ å¹¶éæææ ç¾é½å¯ä»¥å name屿§(大家å¯ä»¥æ¿æä¸é¢çä¾åå» validator.w3.org åéªè¯)
ããæä»¥ä½ ç»divå name屿§çè®ºä¸æ¯ä¸ä¼åºç»æç.è¿ä¸ç¹IEå¾å¥½ç符åäºæ å~!!
ãã(åæ¶ä¹çåºäºç¬¦åæ å乿ç¦äººçå°æ¹~_~ æä»¥å¤§å®¶ä¸ç¨å¤ªææ åå½åäºå¿ è¿ä¸¤å¹´é½ç¨xmläº è¿ä¸ªä¹è¿æ¶äº!å¡å¯¼çµæ´»çwebstandardåºç¨ææ³ é¤äºç¬¦åxmlææ³çä¸è¥¿ å ¶ä»çææµè§å¨ççè§£å»åå°±è¡)
é:
[Ctrl+A å ¨é æ³¨:å¦éå¼å ¥å¤é¨Jséå·æ°æè½æ§è¡]
ããç®åæ¥è¯´å°±æ¯DIV䏿¯æNAME屿§ï¼æä»¥é£ä¸ªdocument.getElementsByNameçä¾åè°è¯ä¸è½éè¿.
ä¸é¢ç¨INPUTå个ä¾å

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Once you have mastered the entry-level TypeScript tutorial, you should be able to write your own code in an IDE that supports TypeScript and compile it into JavaScript. This tutorial will dive into various data types in TypeScript. JavaScript has seven data types: Null, Undefined, Boolean, Number, String, Symbol (introduced by ES6) and Object. TypeScript defines more types on this basis, and this tutorial will cover all of them in detail. Null data type Like JavaScript, null in TypeScript

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

JavaScript can be run in PowerPoint, and can be implemented by calling external JavaScript files or embedding HTML files through VBA. 1. To use VBA to call JavaScript files, you need to enable macros and have VBA programming knowledge. 2. Embed HTML files containing JavaScript, which are simple and easy to use but are subject to security restrictions. Advantages include extended functions and flexibility, while disadvantages involve security, compatibility and complexity. In practice, attention should be paid to security, compatibility, performance and user experience.
