How JavaScript supports W3C DOM templates
This Document Object Model allows access to all document content and modifications, as standardized by the World Wide Web Federation (W3C. Almost all modern browsers support this mode.
Most of the traditional DOM functions in W3C DOM specifications are added with new important functions. Apart from supporting other array attributes of forms [], images [] and document objects, it defines methods to enable scripts to access and manipulate any document element, not just dedicated component-like forms and images.
Document attributes are stored in W3C DOM:
This model supports all attributes provided by traditional DOM. In addition, here is the document attribute. You can use W3C DOM to access the list:
In W3C DOM:
This model supports all methods provided by traditional DOM. In addition, here is a list of methods supported by W3C DOM:
Example:
This is very easy to manipulate using W3C DOM document elements (access and settings. You can use any method similar to getElementById, getElementsByName, or getelementsbytagname.
The following is an example of accessing the document attributes using the W3C DOM method:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<Html> <Head> <Title> Document Title </title> <Script type = "text/javascript"> <! -- Function myFunc () { Var ret = document. getElementsByTagName ("title "); Alert ("Document Title:" + ret [0]. text ); Var ret = document. getElementById ("heading "); Alert (ret. innerHTML ); } // --> </Script> </Head> <Body> <H1 id = "heading"> This is main title <P> Click the following to see the result: </p> <Form id = "form1" name = "FirstForm"> <Input type = "button" value = "Click Me" onclick = "myFunc ();"/> <Input type = "button" value = "Cancel"> </Form> <Form d = "form2" name = "SecondForm"> <Input type = "button" value = "Don't ClickMe"/> </Form> </Body> </Html> |
Note: For returned objects such as the form and content of this example, we will have to use the attributes of these objects not discussed in this tutorial to access their values.