【问题标题】:IE9 and mailto character limitsIE9 和 mailto 字符限制
【发布时间】:2012-01-15 18:43:16
【问题描述】:

我尝试使用 mailto 和 href 发送预先填充的电子邮件,但是我很快发现 IE9 在识别超过 509 个字符(给予或接受)的 href 时存在问题。基本上,单击链接会打开一个空白页面。我寻找答案并遇到了这个 javascript 解决方案,但它仍然不起作用。

这里是锚标记:

<a href="javascript:doMailto()">Sign up</a>

这是脚本:

var sMailto = "mailto:blah@email.com?body=Dear eyecare professional,%0A%0aTo help us schedule your upcoming webinar, please fill out and return the following information:%0A%0A•  Name:%0A%0A•  Preferred date of webinar* (any Wednesday at 6 pm EST):%0A%0A•  City/State (Optional):%0A%0A•  Comments/Questions/Feedback:%0A%0AUpon receipt, we will send you a link to an upcoming GoTo Meeting webinar on Macula Risk implementation in your clinic. These webinars are regularly held on Wednesdays at 6 pm EST.%0A%0A* If you would like to request training on any other date or time - please note this in the Comments section and we will do our best to accommodate your request.%0A%0AKind Regards,%0A%0AGerry Bruckheimer";

   function doMailto() {
      document.location.href= sMailto;
   }

奇怪的是,这在除了愚蠢的 IE 9 之外的所有其他浏览器中都可以使用。

更新:如果您遇到与我类似的问题,请尝试使用 window.open(url)。我意识到这不是一个完美的解决方案,但它确实有效。

【问题讨论】:

  • 我也有同样的问题。似乎是 sMailTo 长度的问题。如果长度大于 508 个字符,则会失败。
  • 可能也与508的书签长度限制有关

标签: html internet-explorer-9


【解决方案1】:

点击链接时,IE9 的 URL 限制实际上相当高,为 between 5120 and 5150。不幸的是,Javascript hack 在这里无济于事——限制仍然有效。不过我怀疑这是问题所在。

您发送的消息包含一些我不会放在 URL 中的字符,尤其是“•”。您应该在将消息放入链接之前对消息进行 URL 编码(最后一个符号显然编码为 %e2%80%a2)。在将其粘贴到&lt;a&gt; 标记之前,您可以URL encode it in Javascriptmanually encode it with an online tool

在处理 URL(或一般代码)中的奇怪字符时,某些浏览器比其他浏览器更轻松。

希望有帮助

【讨论】:

  • 不幸的是,这不起作用但是我确实找到了解决这个问题的方法:如果你使用 window.open(url) ie9 的行为应该如此。感谢您的帮助,我确实最终使用了那个 url 编码器。
猜你喜欢
  • 2011-11-19
  • 2012-08-14
  • 2011-05-03
  • 2015-03-26
  • 2021-02-06
  • 2014-09-17
  • 2012-07-18
  • 1970-01-01
  • 2016-05-29
相关资源
最近更新 更多