【发布时间】: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的书签长度限制有关