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: Mick White <mwhite13BOGUS@rochester.rr.com>
Date: Thu Jun 23 2005 - 18:57:15 CEST

Markus Ernst wrote:

[snip]
> function aktiviereLinks() {
> if (document.getElementsByTagName) {
> args = aktiviereLinks.arguments;
> j = args.length;
> while (j--) {
> a = document.getElementById(args[j]).getElementsByTagName("a");
> i = a.length;
> while (i--) {
> a[i].onmouseover = a[i].onfocus = machAktiv;
> a[i].onmouseout = a[i].onblur = machPassiv;
> }
> }
> }
> }
>

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

See rewritten function below:

function aktiviereLinks() {
     if (document.getElementsByTagName) {

         var j = arguments.length;
         while (j--) {
             a = document.getElementById(args[j]).getElementsByTagName("a");
             var i = a.length;
             while (i--) {
                 a[i].onmouseover = a[i].onfocus = machAktiv;
                 a[i].onmouseout = a[i].onblur = machPassiv;
             }
         }
     }
}

Mick
Received on Tue Oct 18 02:47:56 2005