views:

39

answers:

1

Here's the code I'm trying to understand:

noniefix.js:

function fixNonIE() {
if(YAHOO.env.ua.ie > 0) {
    return false;
}
var divs = YAHOO.util.Dom.get('bd').getElementsByTagName('div');
if(divs.length > 0) {
    YAHOO.util.Dom.batch(divs, pushup);
    alert (divs.length+" divs in file!");
}
}

function pushup(el) {
if(el.id.search('fixer') != -1) {
    return;
}
if(el.innerHTML.search('javascript:textWindow') != -1) {
    el.style.zIndex = parseInt(el.style.zIndex) + 1;
}
var pushupTags = Array('p');
if(pushupTags.length > 0) {
    for(var t=0; t<pushupTags.length; t++) {
        var elems = el.getElementsByTagName(pushupTags[t]);
        YAHOO.util.Dom.batch(elems, (function(e) { e.style.marginTop=0; e.style.marginBottom=0; })); //what's happening HERE?
    }
}
return;
}

I've read up a bit on YUI, so I know that the batch function just takes an array of elements and applies the function to each element. What I don't understand is where the marginTop, marginBottom changes are applied. I think they are applied to each <p> tag, but I've viewed the source code of the page and can't find where this code is being inserted.

Any ideas would be greatly appreciated!

A: 

You can't see result of this function at the source code because it appplys dynamicly by JS to the each DOM tag written in array. But you can see the changes using some debugger software, builded in Internet Explorer 8 for example, or firebug under Mozilla Firefox.

antyrat