Hi,
Assuming that the number of digits in the width is not a certainty
(ie. could be 500 or 67 or 1005) then you can do it by splitting the
string on a space, looping the results to find the width, and
splitting the width on the equals sign. Just like this...
function getWidth() {
img = "../graphics/press/012.jpg' width=23 height=339";
imgArray1 = img.split(" ");
for (i=0; i<imgArray1.length; i++) {
if (imgArray1[i].indexOf("width=")!=-1) {
imgArray2 = imgArray1[i].split("=");
imgWidth = imgArray2[1];
alert(imgWidth);
}
}
}
btw - I flipped the quotes, but I think it can work either way.
best,
jon
http://www.gurupika.com/ http://forums.gurupika.com/