Can't cancel .onmousemove in NN

C

Csaba2000

If you click on or in a table and move the mouse, the default
action is that the "in between" text is supposed to get hilighted.

I can't seem to cancel this behaviour for NN 6.1. The code
below shows a way to do it for IE 5.5. This is not a major
issue, but I'd like to tidy up my code in this respect. Any
pointers appreciated.


As a side note, NN 6.1, in the code below, is nice enough to
note when there is a mouseup even when the mouse has
left the document area. IE loses track of the mouse status
once the mouse has exited the document area and won't
register the next mouseup even if the mouse returns over
the document.

On the other hand, IE does notify us that the mouse is
leaving the document area, whereas I haven't found a
way to do this with NN.

Opera doesn't like the document.on... constructs, but
when replaced with document.body.on... it will lose
track of the mouse when the mouse exits the body
area along certain paths (south, then west - no kidding).
It is also not cancelling the selection action.

Thanks,
Csaba Gabor from New York

<BODY style="border:solid 1px red">
<TABLE border onmousedown="dragMode(event)">
<TR>
<TD>foo</TD><TD>bar</TD>
<TR></TR>
<TD>baz</TD><TD>frob</TD>
</TR></TABLE>
<SCRIPT type="text/javascript">
function dragMode(evt) { // setup for dragging
var e = evt || window.event; // debugging
var myTarget = e.target || e.srcElement; // debugging
document.body.onmousemove = hilightCancel;
document.onmouseout = dragEndCheck;
document.onmouseup = function () {dragEnd("drag over: mouseup")};
window.status = "dragStart: " + myTarget.nodeName // debugging
}

function hilightCancel (evt) {
var e = evt || window.event; // debugging
var myTarget = e.target || e.srcElement; // debugging
// if (e.preventDefault) e.preventDefault(); // hasn't made a difference
window.status = "hilightCancel: " + myTarget.nodeName // debugging
return false; // should prevent hilighting
}

function dragEndCheck(evt) {
// needed cause IE forgets mouse status leaving the body/window
var e = evt || window.event;
var myTarget = e.target || e.srcElement;
var related = e.relatedTarget || e.toElement || e.fromElement;
var relatedName = (related&&related.nodeName)?related.nodeName:"none";

if (myTarget.nodeName!="BODY" || relatedName!="BODY") {return false;}
dragEnd ("drag over: " + myTarget.nodeName + " / " + relatedName)
}

function dragEnd(msg) {
document.body.onmousemove = null;
document.onmouseout = null;
document.onmouseup = null;
window.status = msg; // debugging
}
</SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top