Code: Select all
$gantry->addScript('figureWidth.js');
The javascript
Code: Select all
window.addEvent('domready',function() {
var figs = document.getElementsByTagName("figure");
var imgs = document.getElementsByTagName("img");
for (var j = 0; j < figs.length; j++) {
figs[j].style.width = imgs[j].getAttribute("width")+"px";
}
});
It doesn't work. When I check firebug, the figure is set to 460px wide. It says the style is coming from element.style, which means it is hardcoded in the html, but that's not true.
I would really like to stick with straight javascript. P.S. the code worked fine sans window load on JSFiddle.
Any insights?