I have the following code (within an iframe), and it works. In Chrome, the class that I am using never is applied to the image. It gets set as an attribute in the tag, but the style is not applied. How can I fix this, or is this a Chrome bug?
[code]<script type=”text/javascript”>
var is_cover = <?php echo $is_cover; ?>;
var ni = parent.document.getElementById(‘albumPhotos’);
try{
var itm = ‘<img class=”photoAlbum”‘;
if(is_cover==’1’){
itm += ‘ style=”background-color:#cccccc;”‘;
}
itm += ‘ onclick=”loadBody(‘photos’,’id’,'<?php echo mysql_insert_id(); ?>’);” src=”http://img.publicsize.com/photo/<?php echo $dir; ?>/thumb/<?php echo $file; ?>.jpg” />’;
var newdiv = parent.document.createElement(itm);
}catch(e){
var newdiv = document.createElement(‘img’);
newdiv.setAttribute(‘onclick’, “loadBody(‘photos’,’id’,'<?php echo mysql_insert_id(); ?>’);”);
newdiv.setAttribute(‘class’, “photoAlbum”);
newdiv.setAttribute(‘src’, “http://img.publicsize.com/photo/<?php echo $dir; ?>/thumb/<?php echo $file; ?>.jpg”);
if(is_cover==’1′){
newdiv.setAttribute(‘style’, ‘background-color:#cccccc;’);
}
}
if(is_cover==’0′){
ni.insertBefore(newdiv, ni.firstChild.nextSibling);
}else if(is_cover==’1′){
ni.insertBefore(newdiv, ni.firstChild);
}
</script>