Change of background image works in IE only

Hi,

I’m using javascript to change the background image of a table field. I’ve found that it only works correctly in IE. In FF etc, it simply doesn’t change.

What I have is:
Head


function Info(infolink, titlelink){
document.getElementById('Info').src=infolink;
document.getElementById('subTitle').background=titlelink;
}

Body


<td width="343" id="subTitle" name="subTitle" height="33" valign="top" background="images/aboutustitle.png">


<a href="javascript:Info('aboutus.html','images/aboutustitle.png')"></a>
<a href="javascript:Info('whyus.html','images/whyustitle.png')"></a>

The subTitle field background will only change in IE and I can’t figure out why.

Could anyone please help me out?

Thanks,
Rhys

If you’re going to be mixing your JavaScript in with your mark-up like that, then consider using the style attribute rather than the background attribute:


document.getElementById('subTitle').style.backgroundImage= "url('" + titlelink + "')";

Ahh of course. Too many late nights I guess :stuck_out_tongue:

Thanks r51.