mirror of
https://github.com/rn10950/RetroZilla.git
synced 2024-11-09 09:20:15 +01:00
63 lines
1.2 KiB
HTML
63 lines
1.2 KiB
HTML
<html>
|
|
<body>
|
|
The link below has an onmousedown, an onmouseup, and an onmousemove handler.
|
|
Mouseover or click for event info in debug console.
|
|
<a href="jshandlers.html">Link back to this page</a>
|
|
</body>
|
|
<script>
|
|
function findElementByTagName(start, tag)
|
|
{
|
|
var type = start.nodeType;
|
|
|
|
if (type == Node.ELEMENT) {
|
|
|
|
if (tag == start.tagName) {
|
|
//dump ("found one\n");
|
|
return start;
|
|
}
|
|
|
|
if (start.hasChildNodes) {
|
|
var children = start.childNodes;
|
|
var length = children.length;
|
|
var count = 0;
|
|
while(count < length) {
|
|
var ret = findElementByTagName(children[count], tag)
|
|
if (null != ret) {
|
|
return ret;
|
|
}
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function getFirstLink()
|
|
{
|
|
var node = document.documentElement;
|
|
var ret = findElementByTagName(node, "A");
|
|
return ret;
|
|
}
|
|
|
|
function ondown()
|
|
{
|
|
dump("got mousedown in script\n");
|
|
}
|
|
|
|
function onup()
|
|
{
|
|
dump("got mouseup in script\n");
|
|
}
|
|
|
|
function onmove(event)
|
|
{
|
|
dump("got mousemove in script at "+event.clientX+", "+event.clientY+"\n");
|
|
}
|
|
|
|
var l = getFirstLink();
|
|
l.onmousedown = ondown;
|
|
l.onmouseup = onup;
|
|
l.onmousemove = onmove;
|
|
</script>
|
|
</html>
|