netscape, relative td, and images

admin

Administrator
Staff member
Let me explain what I'm trying to do here. I have some code in place to switch the background image of a table cell in Netscape. It looks like this(for the sake of brevity, i'm leaving out extraneous tags) :

function changeBg(id, img)
{
document.layers[id].background.src = img;
}

<style>
.relative { position:relative; }
</style>

<td width="100" class="relative" id="snBg">
<table height="100" background="./images/trans.gif">
<tr>
<td width="100" height="100" valign="top">
<img src=http://www.webdeveloper.com/forum/archive/index.php/"./images/trans.gif" width="19" height="100" name="label"/>
</td>
</tr>
</table>
</td>


Essentially what this does in NS is convert the td assigned the relative class into a layer. Then by calling changeBg with the td/layer's id, you can set the bg image. This works fine. My problem arises when I try to access the "label" image inside the td/layer. I keep getting 'undefined'. I've tried document.layers["snBG"].document.images["label"], document.layers["snBG"].document.images[0], document.images["label"], etc. If I remove the relative class from the td, it no longer converts to a layer and I can access the image just fine in the normal manner. It's only when it is converted into a layer. Any ideas?
 
Back
Top