P
Pugi!
I would like to obtain the the position of backgroundimage of a div because
I use it for animation. The following code works for Internet Explorer
(takes the else if) and returns positionx '10px' and position y '25px' (the
backgroundPosition doesn't work). Opera follows the first road (if) and
returns '10px 25px'. Firefox follows the same road (first if) as Opera but
returns a blank.
if (window.getComputedStyle) {
var stijl = document.defaultView.getComputedStyle(arrSlices[10], '');
// var stijl = window.getComputedStyle(arrSlices[10], '');
var backpos = stijl.getPropertyValue('background-position');
alert(backpos);
} else if (arrSlices[10].currentStyle) {
var backposx = arrSlices[10].currentStyle.backgroundPositionX;
var backposy = arrSlices[10].currentStyle.backgroundPositionY;
alert ('posx = ' + backposx + ' & posy = ' + backposy);
} else {
alert('Your browser does not support this shit!');
}
If I replace background-position with 'width' even Firefox returns a result.
thanx,
Pugi!
I use it for animation. The following code works for Internet Explorer
(takes the else if) and returns positionx '10px' and position y '25px' (the
backgroundPosition doesn't work). Opera follows the first road (if) and
returns '10px 25px'. Firefox follows the same road (first if) as Opera but
returns a blank.
if (window.getComputedStyle) {
var stijl = document.defaultView.getComputedStyle(arrSlices[10], '');
// var stijl = window.getComputedStyle(arrSlices[10], '');
var backpos = stijl.getPropertyValue('background-position');
alert(backpos);
} else if (arrSlices[10].currentStyle) {
var backposx = arrSlices[10].currentStyle.backgroundPositionX;
var backposy = arrSlices[10].currentStyle.backgroundPositionY;
alert ('posx = ' + backposx + ' & posy = ' + backposy);
} else {
alert('Your browser does not support this shit!');
}
If I replace background-position with 'width' even Firefox returns a result.
thanx,
Pugi!