如何将 javascript 添加到电子邮件中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5193860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:19:40  来源:igfitidea点击:

How can I add javascript to an the email?

javascriptemailmime-typesmime

提问by user279244

Is it possible to have a ajax button inside email? I want to add a button similar to the buttons inside a google calendar meeting invitation email.

电子邮件中是否可以有一个ajax按钮?我想添加一个类似于 google 日历会议邀请电子邮件中的按钮的按钮。

Or is there any alternative option???

或者有其他选择吗???

回答by Martijn

Don't count on it. Most if not all mail clients will refuse to run Javascript within an e-mail.

不要指望它。大多数(如果不是全部)邮件客户端将拒绝在电子邮件中运行 Javascript。

If you want to include buttons, insert images with different links to a public web page of yours. Also, do include the button images within the mail message itself (and reference them by Content-ID), since many mail clients nowadays even refuse to load remote images.

如果您想包含按钮,请插入带有不同链接的图像到您的公共网页。此外,一定要在邮件消息本身中包含按钮图像(并通过Content-ID引用它们),因为现在许多邮件客户端甚至拒绝加载远程图像。

This is exactly what Google Calendar does. Of course, Gmail recognizes invitation attachments (text/calendar), and so provides its own interface for the yes/no/maybe buttons.

这正是 Google 日历所做的。当然,Gmail 可以识别邀请附件(text/calendar),因此为是/否/可能按钮提供了自己的界面。

回答by Tom Gullen

Probably not, it depends on mail client but I would be incredibly suprised if I saw any that allowed scripts as this opens the floodgates for huge security compromise risks.

可能不是,这取决于邮件客户端,但如果我看到任何允许的脚本,我会非常惊讶,因为这为巨大的安全妥协风险打开了闸门。

Edit

编辑

Your best option would probably be to look at support for iframes, again though, I would be suprised if many mail clients allowed use of this element.

您最好的选择可能是查看对 iframe 的支持,不过,如果许多邮件客户端允许使用此元素,我会感到惊讶。