开发者

How does it work? - Javascript function to make non-IE fixes using YUI

开发者 https://www.devze.com 2022-12-22 13:29 出处:网络
Here\'s the code I\'m trying to understand: noniefix.js: function fixNonIE() { if(YAHOO.env.ua.ie > 0) {

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号