hi,
im trying to get the size of a css defined background image. and set the tab01 width to the image width size. it works fine but is there a better way (i dont wanna do the .substr())

thanks

pete

Code JavaScript:
obj=document.getElementById('tab01').id;
 
var backgroundImgSrc = getComputedStyle(obj,'').getPropertyValue('background-image');
 
//i need to cut the url(), otherwise its not working with newImg.src
var backgroundIm = backgroundImgSrc.substr(4,backgroundImgSrc.length-5);
 
var newImg = new Image();
newImg.src = backgroundIm;
var width = newImg.width;
 
document.getElementById('tab01').style.width = width + 'px';