|
1 <html> |
|
2 <body> |
|
3 The link below has an onmousedown, an onmouseup, and an onmousemove handler. |
|
4 Mouseover or click for event info in debug console. |
|
5 <a href="jshandlers.html">Link back to this page</a> |
|
6 |
|
7 <p>The link below has an event that should open www.mozilla.org when |
|
8 clicked |
|
9 </p> |
|
10 <!-- The link does 'return 0' - as per bug 345521 this should *not* be |
|
11 interpreted as false |
|
12 --> |
|
13 <a href="http://www.mozilla.org" onclick="return 0">Click me</a> |
|
14 |
|
15 <p>The link below has an event that is cancelled - nothing should happen when |
|
16 clicked |
|
17 </p> |
|
18 <a href="http://www.mozilla.org" onclick="return false">Click me<a/> |
|
19 |
|
20 </body> |
|
21 <script> |
|
22 function findElementByTagName(start, tag) |
|
23 { |
|
24 var type = start.nodeType; |
|
25 |
|
26 if (type == Node.ELEMENT) { |
|
27 |
|
28 if (tag == start.tagName) { |
|
29 //dump ("found one\n"); |
|
30 return start; |
|
31 } |
|
32 |
|
33 if (start.hasChildNodes) { |
|
34 var children = start.childNodes; |
|
35 var length = children.length; |
|
36 var count = 0; |
|
37 while(count < length) { |
|
38 var ret = findElementByTagName(children[count], tag) |
|
39 if (null != ret) { |
|
40 return ret; |
|
41 } |
|
42 count++; |
|
43 } |
|
44 } |
|
45 } |
|
46 return null; |
|
47 } |
|
48 |
|
49 function getFirstLink() |
|
50 { |
|
51 var node = document.documentElement; |
|
52 var ret = findElementByTagName(node, "A"); |
|
53 return ret; |
|
54 } |
|
55 |
|
56 function ondown() |
|
57 { |
|
58 dump("got mousedown in script\n"); |
|
59 } |
|
60 |
|
61 function onup() |
|
62 { |
|
63 dump("got mouseup in script\n"); |
|
64 } |
|
65 |
|
66 function onmove(event) |
|
67 { |
|
68 dump("got mousemove in script at "+event.clientX+", "+event.clientY+"\n"); |
|
69 } |
|
70 |
|
71 var l = getFirstLink(); |
|
72 l.onmousedown = ondown; |
|
73 l.onmouseup = onup; |
|
74 l.onmousemove = onmove; |
|
75 </script> |
|
76 </html> |