JavaScript和电子邮件

When writing an email the two main choices that you have are to write the email in plain text or to use HTML. With plain text all you can place in the email itself is text and anything else must be an attachment. With HTML in your email, you can format the text, incorporate images, and do most of the same things in the email that you can do in a web page.

编写电子邮件时,您有两个主要选择,就是以纯文本格式编写电子邮件或使用HTML。 使用纯文本,您可以在电子邮件本身中放置的所有内容都是文本,其他任何内容都必须是附件。 通过电子邮件中HTML,您可以设置文本格式,合并图像并在电子邮件中执行与在网页中相同的大多数操作。

As you can incorporate JavaScript into HTML in a web page, you can of course similarly incorporate JavaScript into HTML in an email.

由于您可以将JavaScript合并到网页HTML中,因此当然可以类似地将JavaScript合并到电子邮件的HTML中。

为什么HTML电子邮件中不使用JavaScript? ( Why Isn't JavaScript Used in HTML Emails? )

The answer to this relates to a fundamental difference between web pages and emails. With web pages, it is the person browsing the web who decides which web pages they visit. A person on the web is not going to visit pages that they believe may contain anything that might be harmful to their computer such as a virus. With emails, it is the sender who has the most control over what emails are sent and the recipient has less control. The entire concept of spam filtering to try to strip out junk emails that are not wanted is one indication of this difference. Because emails that we don't want can get through our spam filter we want the emails that we do see to be made as harmless as we can make them just in case something destructive does get past our filter. Also while viruses can be attached to both emails and web pages, those in emails are far more common.

答案与网页和电子邮件之间的根本差异有关。 对于网页,由浏览网页的人来决定他们访问哪些网页。 网络上的人不会访问他们认为可能包含可能对计算机有害的任何内容的页面,例如病毒。 对于电子邮件,发件人对发送哪些电子邮件具有最大的控制权,而收件人则没有那么多的控制权。 试图过滤掉不需要的垃圾电子邮件的整个垃圾邮件过滤概念就是这种区别的一种体现。 因为我们不需要的电子邮件可以通过我们的垃圾邮件过滤器,所以我们希望将确实看到的电子邮件变得无害,以防万一有破坏性的邮件通过了过滤器。 同样,尽管病毒可以同时附着在电子邮件和网页上,但电子邮件中的病毒却更为常见。

For this reason, the vast majority of people have the security settings in their email program set much higher than they have set in their browser. This higher setting usually means that they have their email program set up to ignore any JavaScript that might be found in the email.

因此,绝大多数人在电子邮件程序中设置的安全性设置要比在浏览器中设置的安全性设置高得多。 较高的设置通常意味着他们设置了电子邮件程序,以忽略可能在电子邮件中找到的任何JavaScript。

Of course, the reason why most HTML emails don't contain JavaScript because they don't have any need for it. Where there would be a use for JavaScript in an HTML email those who understand that JavaScript is disabled in most email programs will produce an alternative solution where the email links to a web page that contains the JavaScript.

当然,大多数HTML电子邮件之所以不包含JavaScript的原因是因为它们不需要JavaScript。 那些了解在大多数电子邮件程序中禁用JavaScript的人会在HTML电子邮件中使用JavaScript的情况下 ,将产生一种替代解决方案,其中电子邮件链接到包含JavaScript的网页。

只有将JavaScipt放置在电子邮件中 ( The Only Time JavaScipt Is Placed in Email )

There will only be two groups of people who place JavaScript into their emails — those who have not yet realised that the security settings in email programs are different from that in web pages so that their JavaScript isn't going to run and those who deliberately place JavaScript into their email so that it will automatically install a virus onto the computer of those few people who have the security settings in their browser misconfigured so that their JavaScript can run.

只有两类人将JavaScript放入电子邮件中-尚未意识到电子邮件程序中的安全性设置与网页中的安全性设置不同(从而使他们JavaScript无法运行)的人和故意将其放入电子邮件中的人将JavaScript插入其电子邮件中,以便将病毒自动安装到少数在浏览器中配置了安全设置的人的计算机上,从而使其JavaScript可以运行。

翻译自: https://www.thoughtco.com/javascript-and-emails-2037682

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值