Re: Handle events from central script
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Handle events from central script

From: Markus Ernst <derernst@NO#SP#AMgmx.ch>
Date: Mon Jun 27 2005 - 12:31:54 CEST

Mick White wrote:
>
> Couple of things:
> [1] "Function.arguments" deprecated
> [2] Localize scope of loop variables (i & j)
>

Thanks a lot. Now I added a recursive function call to make the hover in all
elements up to the next <div> element:

function machAktiv() {
    var pN = this.parentNode;
    umschalten(pN, "aktiv");
}
function machPassiv() {
    var pN = this.parentNode;
    umschalten(pN, "passiv");
}
function umschalten(pN, klasse) {
    if (pN) {
        var kl = klasse;
        if (pN.className.indexOf("Unten") != -1) kl = kl + "Unten";
        pN.className = kl;
        if (pN.nodeName.toLowerCase() != "div") umschalten(pN.parentNode,
klasse);
    }
}
function aktiviereLinks() {
    if (document.getElementsByTagName) {
        var j = arguments.length;
        while (j--) {
            a =
document.getElementById(arguments[j]).getElementsByTagName("a");
            var i = a.length;
            while (i--) {
                a[i].onmouseover = a[i].onfocus = machAktiv;
                a[i].onmouseout = a[i].onblur = machPassiv;
            }
        }
    }
}

So in the following HTML the "person" element and all children will be
highlighted if one of the links is hovered:

<body onLoad="aktiviereLinks('head')">
    <div id="person" class="passiv">
        <img src="myimage.gif" alt="">
        <p class="passiv">
            My name<br>
            <a href="mailto:mail@domain.com">mail@domain.com</a><br>
            <span class="passiv"><a
href="http://www.domain.com">www.domain.com</a></span>
        </p>
    </div>
</body>

Thank you all for your help!!
Markus
Received on Tue Oct 18 02:49:14 2005