HTML电子邮件模板解决方案表TD中的javascript链接?

时间:2013-07-22 09:26:18

标签: javascript html css

这是我目前的代码:

<td height="150" style="background: url(bg.jpg); cursor: pointer;" onClick="document.location.href='http://www.youtube.com';">

现在很明显,使用JavaScript,这不太适用于电子邮件客户端(是吗?)。什么是HTML解决方案?提前致谢!我已经尝试过包装链接标签,但这似乎没有诀窍。

3 个答案:

答案 0 :(得分:2)

为什么不直接设置链接以占用td的宽度和高度:

<td height="150" style="background: url(bg.jpg);"><a href="http://www.youtube.com" style="display:block;height:150px;width:100%;"></a></td>

答案 1 :(得分:0)

你不能这样打字:

<td height="150"><a href="http://www.youtube.com"><img src="bg.jpg" /></a></td>

答案 2 :(得分:0)

根据您发布的信息(以及您对@ PAM答案的评论),我认为这将解决您的问题:

<td width="150" style="background-color:rgb(128,128,128); background-image:url('http://www.yoursite.com/yourpicture.gif'); cursor:pointer;">
<a href="http://www.youtube.com">

...Text...

</a>
</td>

我已将background-color属性添加到td,以便用户在其电子邮件客户端不显示背景图片时可以进行备用。当然,您应该将其设置为与背景图像类似的颜色。