Is JavaScript supported in an email message?

前端 未结 10 1043
太阳男子
太阳男子 2020-11-22 14:37

Is JavaScript supported in an email message?

10条回答
  •  情深已故
    2020-11-22 14:57

    Short answer

    No


    Descriptive answer

    It depends. But the email is not guaranteed to behave in the way you want it to. Different email clients handle JS differently. Most of the newer email clients do not support any of it since it is potentially very dangerous to support script execution in a desktop application which contains so much of your personal info.

    I had a use case where I needed to use JS in an email. I tried out on the web client of outlook and desktop client as well, and it turns out outlook just wipes out the script part of your HTML email. There might be some other email client which does support JS execution, but given that you cannot control the client where your email would be viewed in the client machine, it's not a good idea to embed any scripts in the HTML email.

    Its advised to keep your HTML email as simple as possible, no JS, and the least CSS you can do with (because, again, different email clients have varying support for CSS as well) eg: outlook's web client was not even recognizing an HTML button tag in the email. I had to use an anchor tag and some CSS on top of it to mimic the display of a button.


    Bottom line - don't rely on Javascript when working with HTML email content.

提交回复
热议问题