Click to See Complete Forum and Search --> : Background: onClick Link


Cory R
05-21-2008, 07:21 PM
Here's my coding:

<td class="fht3" align="center" onclick="self.location='http://bigboardsresources.com/index.php?showtopic=2315'" style="background:url(http://img293.imageshack.us/img293/8113/fhighlitetablerty1.png);cursor:pointer"><span class="fht"><br><a href="http://hcwfed.co.nr/" target="_blank"><img src="http://209.85.48.8/9764/158/upload/p3694271.gif" border="0" alt="HCW" title="Hardcore Championship Wrestling" width="88" height="31"></a></span><br></td>
I made the background clickable with self.location, as you can see. All is well, however, when you click the image (img not background) placed in the table cell, the link that's suppose to open in a new window will and the background will also open in the same window. How do I stop the background link from opening too when I click the image placed within the cell?

ray326
05-21-2008, 07:52 PM
Well for starters you've got nested anchors, which isn't valid HTML.

Cory R
05-21-2008, 11:16 PM
So, ultimately, having a clickable background image and a clickable image placed on the background like my coding above isn't valid coding (or possible)?

Cory R
05-23-2008, 09:56 PM
So, anyone have any information on clickable background images?

ray326
05-24-2008, 12:07 AM
You don't have to have an anchor to capture an onclick event.

Cory R
05-24-2008, 03:02 AM
Not quite sure what you mean by that, as the onClick event is being used in the TD tag, not the anchor tag.

ray326
05-24-2008, 01:51 PM
Ok, I'll reformat it so I can read it. I don't know why I thought I saw nested anchors in the first place.

<td class="fht3" align="center"
onclick="self.location='http://bigboardsresources.com/index.php?showtopic=2315'"
style="background:url(http://img293.imageshack.us/img293/8113/fhighlitetablerty1.png);cursor:pointer">
<span class="fht">
<br>
<a href="http://hcwfed.co.nr/" target="_blank">
<img src="http://209.85.48.8/9764/158/upload/p3694271.gif" border="0" alt="HCW" title="Hardcore Championship Wrestling" width="88" height="31">
</a>
</span>
<br>
</td>

Maybe adding an onclick to the anchor would capture the event and keep it from passing through to the other one. Use it to open your new window then return false.