Joachim: Position eines IMG im Fenster

Beitrag lesen

hi,

wenn das bild _nicht_ in positionierbaren Elementen steckt:

// ab js1.2
function findPos(el) {

var xPos    = 0;
    var yPos    = 0;

if(document.layers) {
            xPos = el.x;
            yPos = el.y;
    }
    else {
        while(el){
            xPos += el.offsetLeft;
            yPos += el.offsetTop;
            el   =  el.offsetParent;
        }
    }
    return {xPos: xPos, yPos: yPos};
}

gib dem Bild einen Namen. Position findest Du dann so heraus

var x = findPos('document.bildname').xPos;
var y = findPos('document.bildname').yPos;

hth

Gruesse  Joachim