Forum Moderators: open
<A HREF="javascript: openmypage()" onMouseOver="window.status='New Flavor Apple Spice';return true;" onMouseOut="self.status=''" onclick="window.focus()"><TD VALIGN=bottom ROWSPAN=2><FONT FACE="geneva, arial, helvetica, sans-serif" SIZE="2"><TABLE BORDER="0" HEIGHT="440" WIDTH="350" CELLSPACING="0" CELLPADDING="0" BACKGROUND="images/apple_spice_announcement.jpg"></A></td>
It doesn't work if I do it that way, but if I take the image out of the table data, like so:
<TD VALIGN=bottom ROWSPAN=2><FONT FACE="geneva, arial, helvetica, sans-serif" SIZE="2"><TABLE BORDER="0" HEIGHT="440" WIDTH="350" CELLSPACING="0" CELLPADDING="0"><A HREF="javascript: openmypage()" onMouseOver="window.status='New Flavor Apple Spice';return true;" onMouseOut="self.status=''" onclick="window.focus()"><IMG SRC="images/apple_spice_announcement.jpg" Alt="Click here for more info on whatever!" BORDER="0" width="350" height="440"></A></td>
then I get desired result. The problem is, by taking the image out of the table data and setting it out on its own, another table that I use for contact info on the bottom of the page which is visible without scrolling, gets knocked way down the page so you have to scroll down to see it. Is there some way of making a background image inside of <td> a link or not? If not, I think i'll bust out some <div> tags for the contact info, unless someone has an idea...
In the first snippet, you have:
start A
start TD
start TABLE
close A
close TD
In the second you start a TD, start a TABLE, start an A (anchor), close the A tag, and then close the TD. What happened with the table?
To answer your question:
You can add an onclick attribute to the TD itself. With the image as a background, I think that would give you the effect you are looking for. If you do this, then you will probably also want to set the cursor using the TD's style.
Try this:
<TABLE BORDER="0" HEIGHT="440" WIDTH="350" CELLSPACING="0" CELLPADDING="0">
<tr>
<TD VALIGN="bottom" ROWSPAN="2">
<A HREF="mypage.htm" onClick="openmypage(); return false;"
onMouseOver="window.status='New Flavor Apple Spice';return true;"
onMouseOut="self.status=''"><IMG SRC="images/apple_spice_announcement.jpg"
Alt="Click here for more info on whatever!"
BORDER="0" width="350" height="440"></A>
</td>
</tr>
<tr><td>Whatever's in the second row from rowspan=2 above</td></tr>
</table>
A couple things to mention:
1. Note the nesting. <table><tr><td><a></a></td></tr></table>
2. In your href - note that href="now your page." If Javascript is disabled, you still want them to see this page. The return false in the onClick event handler tells Javascript NOT to actually move to that page. So if JS is enabled, it won't go, but if it's disabled, the user still sees the data.
3. Note I've removed the evil font tag (which also did not have a closing </font>.) Put the following in the head of your document:
<style type="text/css">
html,body { font-family:Arial, Helvetica, Sans-Serif; }
</style>
And all your text will be in that style. Since what's in the TD is NOT text, you don't need it anyway, but in the event you do, this will set the font for you.
<TR></a>
<TD VALIGN=top><FONT FACE="Times" SIZE="2"><B>
<CENTER>
<BR><BR>
<TABLE BORDER="0" CELLSPACING="6" CELLPADDING="6">
<TR><TD><FONT FACE="times, times new roman" SIZE="2"><B>
</TD></TR>
</TABLE>
I don't know what that second TD VALIGN is doing. It doesn't look like there's anything in it.
I don't know what that second TD VALIGN is doing. It doesn't look like there's anything in it.
If that's what your source code show, you're right -- looks like leftover debris from earlier editing, and it is doing nothing.
I strongly encourage you to use the W3C Validator for HTML [validator.w3.org] to sort things out. It can save untold aggrivation.
The only place inside a table that you can have user content, is inside a single <td>..</td> cell.
Get the nesting right, and it will work fine. While there, get rid of the <font> tags and invest in half a dozen lines of CSS to style the entire site.