如何在电子邮件中插入内部链接?
这是我在浏览器中打开的html,在gmail中复制粘贴,发送给自己并希望其内部链接正常工作:
<html>
<body>
<p><a href="#Title1" title="Click to go to Title 1">Birds</a></p>
<p><a href="#Title2" title="Click to go to Title 2">Trees</a></p>
<p><a href="#Title3" title="Click to go to Title 3">Flowers</a></p>
<h4 id="Title1">Birds</h4>
<p> There are many different birds. There are... </p>
<h4 id="Title2">Trees</h4>
<p> Trees have many different colors and branches... </p>
<h4 id="Title3">Flowers</h4>
<p> The Lignum Vitae is the national flower of Jamaica... </p>
</body>
</html>
修改:
我将以下内容发送给自己:
<html>
<body>
<p><a href="#Title1" title="Click to go to Title 1">Birds</a></p>
<p><a href="#Title2" title="Click to go to Title 2">Trees</a></p>
<p><a href="#Title3" title="Click to go to Title 3">Flowers</a></p>
<h4 id="Title1"><a name="Title1">Birds</a></h4>
<p> There are many different birds. There are... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
<h4 id="Title2"><a name="Title2">Trees</a></h4>
<p> Trees have many different colors and branches... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
<h4 id="Title3"><a name="Title3">Flowers</a></h4>
<p> The Lignum Vitae is the national flower of Jamaica... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
</body>
</html>
并且链接无法点击。我做错了什么?
答案 0 :(得分:5)
在 gmail 中,您需要使用命名锚:
<a name="Title1">Birds</a>
正如您所料,不同的电子邮件客户端......工作方式不同。一些支持ID的内部链接;有些人没有;一些支持。 AFAIK gmail仅支持命名的锚点。请记住,可能会有一些电子邮件客户端根本不支持内部链接。
id
中的h4
并非绝对必要,因为命名锚点应该适用于大多数电子邮件客户端。但是,就我所知,没有理由不同时拥有这两者。以下适用于我的Gmail:
<h4 id="Title1"><a name="Title1">Birds</a></h4>
但是,应该注意的是,Gmail似乎会使用JavaScript覆盖默认的浏览器/ HTML功能(并在命名锚点和相应的href中插入前缀,以免干扰其Web界面)。因此, Gmail似乎只会滚动到指定的锚点,如果它当前不在视图中 - 如果它已经可见,则不会发生滚动。