Some basic usage in Web standard development (serialization ...)

Source: Internet
Author: User
Some basic usage in Web standard development (serialization ...)

In Web programming, we usually use a text-based approach, that is, using the vertex method to access and set, such as: Document. All. Id. value = "value"

Browsers that do not support W3C Dom and those that do not support DOM at all

The browser supports this web programming approach (text-based Web programming ).

 

Before the W3C Dom standard emerged, both ie4 and ns4 of Micrsoft and Netscape had their own Dom standards, browsers that mainly support W3C Dom standards should:

Netscape 6.0 +, Mozilla 0.9 +

IE/win 5 +, ie/MAC 5 +

Opera7 +

And other browsers with few users

 

Dom standard (Document Object Model) is based on Dom web programming.

In Dom, the HTML document hierarchy is represented as a tree structure. Node representation of the tree

Various content in the document

 

 

The following describes some basic usage of Web standard development:

1. obtain a control (ID = "control "):

VaR element = Document. getelementbyid ("control ");

2. If the above control is a tag, obtain its content:

VaR text = element. childnodes [0];

3. Set the properties of the control:

A) Apart from style, class, and Event Response attributes, other attributes can be set as follows:

Element. setattribute ("readonly", "true ");

B) set the class attribute:

Element. setattribute ("calssname", "test ");

C) Set Event Response attributes: (attachevent () is supported by IE, and addeventlistener () must be used in Mozilla ().)

Element. attachevent ("onclick", test); (ie5/MAC is not supported)

Element. addeventlistener ("eventtype", listenerreference, captureflag); (ie5/MAC is not supported)

(The first parameter is a string that declares the event type (without the "on" prefix), such as click, mousedown, and keypress. The second parameter of the addeventlistener () method can be treated the same as the function reference described earlier. The third parameter is a Boolean value, indicating whether the node uses the so-called capture mode in the dom-combined as event propagation-which is finally described in another article. For a typical event listener, the third parameter should be false ).) To listen for events. Event capturing and dispatching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.