dom/tests/html/jshandlers.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/html/jshandlers.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +<html>
     1.5 +<body>
     1.6 +The link below has an onmousedown, an onmouseup, and an onmousemove handler.
     1.7 +Mouseover or click for event info in debug console.
     1.8 +<a href="jshandlers.html">Link back to this page</a>
     1.9 +
    1.10 +<p>The link below has an event that should open www.mozilla.org when 
    1.11 +   clicked
    1.12 +</p>
    1.13 +<!-- The link does 'return 0' - as per bug 345521 this should *not* be 
    1.14 +     interpreted as false
    1.15 +-->
    1.16 +<a href="http://www.mozilla.org" onclick="return 0">Click me</a>
    1.17 +
    1.18 +<p>The link below has an event that is cancelled - nothing should happen when 
    1.19 +   clicked
    1.20 +</p>
    1.21 +<a href="http://www.mozilla.org" onclick="return false">Click me<a/>
    1.22 +
    1.23 +</body>
    1.24 +<script>
    1.25 +function findElementByTagName(start, tag)
    1.26 +{
    1.27 +    var type = start.nodeType;
    1.28 +
    1.29 +    if (type == Node.ELEMENT) {
    1.30 +
    1.31 +		if (tag == start.tagName) {
    1.32 +			//dump ("found one\n");
    1.33 +			return start;
    1.34 +		}
    1.35 +
    1.36 +        if (start.hasChildNodes) {
    1.37 +            var children = start.childNodes;
    1.38 +            var length = children.length;
    1.39 +            var count = 0;
    1.40 +            while(count < length) {
    1.41 +				var ret = findElementByTagName(children[count], tag)
    1.42 +				if (null != ret) {
    1.43 +					return ret;
    1.44 +				}
    1.45 +                count++;
    1.46 +            }
    1.47 +        }
    1.48 +    }
    1.49 +	return null;
    1.50 +}
    1.51 +
    1.52 +function getFirstLink()
    1.53 +{
    1.54 +	var node = document.documentElement;
    1.55 +	var ret = findElementByTagName(node, "A");
    1.56 +	return ret;
    1.57 +}
    1.58 +
    1.59 +function ondown() 
    1.60 +{
    1.61 +	dump("got mousedown in script\n");
    1.62 +}
    1.63 +
    1.64 +function onup()
    1.65 +{
    1.66 +	dump("got mouseup in script\n");
    1.67 +}
    1.68 +
    1.69 +function onmove(event)
    1.70 +{
    1.71 +	dump("got mousemove in script at "+event.clientX+", "+event.clientY+"\n");
    1.72 +}
    1.73 +
    1.74 +var l = getFirstLink();
    1.75 +l.onmousedown = ondown;
    1.76 +l.onmouseup = onup;
    1.77 +l.onmousemove = onmove;
    1.78 +</script>
    1.79 +</html>

mercurial