PDA

View Full Version : IE problem - appendChild or other reason?



jonas-e
08-03-2009, 06:40 PM
I have a problem with this peace of JS - it works fine in Firefox and Chrome - but not in IE(7). I keep staring at it but I can't figure it out - any ideas which part is not supported in IE7 and what the workaround is?


<div id="picasaAlbums" style="border:0px solid #888888;width:80%;margin:auto;"></div>

<script type='text/javascript'>
var albumsDiv = document.getElementById('picasaAlbums');
for (var i=0; i<5; i++) {
var link = document.createElement('a');
link.href = 'http://www.example.com/';
link.target = '_blank';

var img = document.createElement('img');
img.src = 'images/test.jpg';
img.style.border='none';
link.appendChild(img);

var title = document.createElement('p');
title.style.width = img.width+'px';
title.style.fontSize = '9px';
title.innerHTML = 'This is the title';

var containor = document.createElement('div');
containor.style.border='1px solid grey';
containor.style.margin='2px';
containor.style.padding='2px';
containor.style.float='left';
containor.style.width = '146px';
containor.style.height = '200px';
containor.style.overflow = 'hidden';
containor.style.fontFamily = 'Verdana, Arial, sans-serif';

containor.appendChild(link);
containor.appendChild(title);

albumsDiv.appendChild(containor);
}
</script>


BTW: "containor.style.float='left';" doesn't work in Firefox 3.5 - but I will put it in a css file eventually.