1

I am sending an email from my SAP System to gmail. The body is html and javascript based content. Now, the requirement is to create a new url window onclick of a button or a link inside the email which will open a web page in a popup window.

So, when i am testing it within SAP, it is working correctly but when i am testing it within the gmail application, it is calling the URL in a new Tab(Full Page). As it is just an informational window, i want to keep it as small as possible.

Here is my code for the email content

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">function target_popup(form){    
window.open("","formpopup","width=3000,height=40,resizable,scrollbars");
form.target="formpopup";}
</script>
<form action="https://testapp.html"  onsubmit="target_popup(this)">
<input type="submit" value="Go to Google" />
</form>
</body>
</html>                                                                                                                                                                             
vwegert
  • 18,371
  • 3
  • 37
  • 55
Sourav Das
  • 982
  • 1
  • 15
  • 40
  • 5
    e-mail clients [do not reliably support javascript](https://stackoverflow.com/questions/2520300/how-to-embed-functionality-into-html-email), and many have it turned off for security reasons. don't do this, there's a better way to do things (use an ``). – Dan Sep 17 '16 at 19:58
  • 1
    @DanPantry Strike "reliably". No sane email client will run Javascript at all, even a little bit. –  Sep 17 '16 at 20:06
  • Not making any guarantees about the sanity of any given e-mail client. I was trying to say that yes it's theoretically possible but practically, no, it's a goose chase :) – Dan Sep 17 '16 at 20:06
  • 1
    @SouravDas You don't. You should not forcibly make decisions on how the window should be sized, that's bad UX. Lots of malicious ads used the ability to do that a few years ago by creating a window that would be resized and then continually reposition itself around the screen every time you got close to the X button. – Dan Sep 17 '16 at 20:20
  • 1
    Questions like this makes me glad that no sane email client ever executes JS. – Terry Sep 17 '16 at 21:16
  • @DanPantry Thanks a lot for clarification. – Sourav Das Sep 17 '16 at 21:26

1 Answers1

13

All email clients have (and must have) a strict policy against running any Javascript found in emails.

This is a strong security requirement, you will not get around it. Which is good. You can only place Javascript on the target site, not in the email.

fdreger
  • 12,264
  • 1
  • 36
  • 42