Window Browser JavaScript DHTML

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 
John Wiley & Sons CopyRight 2001
*/



function setDocCapture(enable) {
    if (!enable) {
        document.captureEvents(Event.CLICK)
    } else {
        document.releaseEvents(Event.CLICK)
        document.forms[0].setDocRte.checked = false
        docRoute = false
    }
    
}
function setLayerCapture(enable) {
    if (!enable) {
        document.layer1.captureEvents(Event.CLICK)
    } else {
        document.layer1.releaseEvents(Event.CLICK)
        document.forms[0].setLyrRte.checked = false
        layerRoute = false
    }
}
var docRoute = false
var layerRoute = false
function setDocRoute(enable) {
    docRoute = !enable
    document.forms[0].setDocShortCircuit.checked = false
    docShortCircuit = false
}
function setLayerRoute(enable) {
    layerRoute = !enable
    document.forms[0].setLyrShortCircuit.checked = false
    layerShortCircuit = false
}
var docShortCircuit = false
var layerShortCircuit = false
function setDocShortcut(enable) {
    docShortCircuit = !enable
    if (docShortCircuit) {
        document.forms[0].setDocRte.checked = false
        docRoute = false
    }
}
function setLayerShortcut(enable) {
    layerShortCircuit = !enable
    if (layerShortCircuit) {
        document.forms[0].setLyrRte.checked = false
        layerRoute = false
    }
}
function doMainClick(e) {
    if (e.target.type == "button") {
        alert("Captured in top document")
        if (docRoute) {
            routeEvent(e)
        } else if (docShortCircuit) {
            document.layer1.document.forms[0].layerButton2.handleEvent(e)
        }
    }
}
document.captureEvents(Event.CLICK)
document.onclick=doMainClick



Redirecting Event.CLICK



 onMouseDown="setDocCapture(this.checked)" CHECKED>Enable Document Capture 
 onMouseDown ="setDocRoute(this.checked)">And let event continue
onMouseDown ="setDocShortcut(this.checked)">Send event to 'layerButton2'


 onMouseDown ="setLayerCapture(this.checked)" CHECKED>Enable Layer Capture 
 onMouseDown ="setLayerRoute(this.checked)">And let event continue
onMouseDown ="setLayerShortcut(this.checked)">Send event to 'layerButton2'




    onClick="alert('Event finally reached Button:' + this.name)">




function doLayerClick(e) {
    if (e.target.type == "button") {
alert("Captured in layer1")
        if (layerRoute) {
            routeEvent(e)
        } else if (layerShortCircuit) {
            document.forms[0].layerButton2.handleEvent(e)
        }
    }
}
layer1.captureEvents(Event.CLICK)
layer1.onclick=doLayerClick

 
 
 
 layer1

    NAME="layerButton1" 
    onClick="alert('Event finally reached Button:' + this.name)">

 

    NAME="layerButton2" 
    onClick="alert('Event finally reached Button:' + this.name)">