JavaScript & DHTML Cookbook
by Danny Goodman
THe following error was *corrected* in the 3/06 reprint:
Here's a key to the markup:
[page-number]: serious technical mistake
{page-number}: minor technical mistake
: important language/formatting problem
(page-number): language change or minor formatting problem
{396} initDrag() function;
// Assign event handlers used by both Navigator and IE
function initDrag() {
if (document.layers) {
// turn on event capture for these events in NN4 event model
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
return;
} else if (document.body & document.body.addEventListener) {
//turn on event capture for these events in W3C DOM event model
document.addEventListener("mousedown", engage, true);
document.addEventListener("mousemove", dragIt, true);
document.addEventListener("mouseup", release, true);
}
document.onmousedown = engage;
document.onmousemove = dragIt;
document.onmouseup = release;
return;
}
NOW READS:
// Assign event handlers used by both Navigator and IE
function initDrag() {
if (document.layers) {
// turn on event capture for these events in NN4 event model
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
return;
}
document.onmousedown = engage;
document.onmousemove = dragIt;
document.onmouseup = release;
return;
}