|
1 <HTML> |
|
2 <HEAD> |
|
3 <TITLE>Attributes test</TITLE> |
|
4 </HEAD> |
|
5 <BODY bgColor="#ffffff" text="#000000"> |
|
6 <H1>Attributes test</H1> |
|
7 |
|
8 <P>You should see the following in the console:</P> |
|
9 <PRE> |
|
10 attribute.getNamedItem == getAttributeNode: true |
|
11 attribute BGCOLOR=#ffffff |
|
12 changing attribute node value changes attribute value: true |
|
13 return value of removeNamedItem is attribute node: true |
|
14 removing attribute changes attribute count: true |
|
15 changing disembodied attribute value works: true |
|
16 removing attribute node removes attribute: true |
|
17 </PRE> |
|
18 |
|
19 <P>The text should turn green and then you should see |
|
20 the following in the console:</P> |
|
21 <PRE> |
|
22 setting an existing attribute returns the old node: true |
|
23 </PRE> |
|
24 |
|
25 <SCRIPT> |
|
26 a = document.body.attributes.getNamedItem("bgcolor") |
|
27 a2 = document.body.getAttributeNode("bgcolor") |
|
28 n = document.body.attributes.length; |
|
29 dump("attribute.getNamedItem == getAttributeNode: " + (a == a2) + "\n"); |
|
30 |
|
31 dump("attribute " + a.name + "=" + a.value + "\n"); |
|
32 |
|
33 a.value = "#00ffff" |
|
34 dump("changing attribute node value changes attribute value: " + (document.body.getAttribute("bgcolor") == "#00ffff") + "\n"); |
|
35 |
|
36 a = document.body.attributes.removeNamedItem("bgcolor") |
|
37 dump("return value of removeNamedItem is attribute node: " + (a == a2) + "\n"); |
|
38 |
|
39 dump("removing attribute changes attribute count: " + (document.body.attributes.length == (n-1)) + "\n"); |
|
40 |
|
41 a.value = "#ff0000" |
|
42 dump("changing disembodied attribute value works: " + (a.value == "#ff0000") + "\n"); |
|
43 |
|
44 dump("removing attribute node removes attribute: " + (document.body.getAttribute("bgcolor") == "") + "\n"); |
|
45 |
|
46 a = document.body.attributes.getNamedItem("TEXT"); |
|
47 a2 = document.createAttribute("text"); |
|
48 a2.value = "#00ff00"; |
|
49 a3 = document.body.attributes.setNamedItem(a2); |
|
50 dump("setting an existing attribute returns the old node: " + (a == a3) + "\n"); |
|
51 </SCRIPT> |
|
52 |
|
53 </BODY> |
|
54 </HTML> |
|
55 |