0

I am developing a page, which will be sent to people as email. Just like advertisement emails which we usually get. I wanted to know that it will support only html-php or can we use javascript and jquery also in that. Thank You for help!

vikram
  • 189
  • 3
  • 13
  • Possible duplicate of [Is JavaScript supported in an email message?](http://stackoverflow.com/questions/3054315/is-javascript-supported-in-an-email-message) – Russell Young Jun 23 '16 at 07:31

2 Answers2

0

Generally no you cant use javascript in an email body, but it will depend on the email client used to view the email as to whether it's allowed or not. It'd bad practise generally, and if you do this the majority of your mails will not get to their destination. Also bear in mind the HTML and CSS supported by email clients is limited, so don't expect a page that works in your web browser to look the same on an email client.

You can of course use javascript to help render the body of the message, and then extract the HTML/CSS that's been generated, but don't include any of the javascript code itself in the body that gets sent.

This looks like a duplicate of Is JavaScript supported in an email message?...

Community
  • 1
  • 1
Russell Young
  • 2,033
  • 1
  • 14
  • 12
  • Yes, But what i want is the countdown timer which will be displaying in the user email. How to do that? – vikram Jun 23 '16 at 07:33
  • The only place Ive seen this kind of thing work is when using an animated GIF - but its never a genuine countdown. You could reference an image that's on your website which you update dynamically on your server that gives the current time remaining, but it'd be difficult to get it animated and accurate! – Russell Young Jun 23 '16 at 07:35
  • Correct, I came accross this one github.com/SeanJA/countdown-clock/blob/master/gif.php, but there is a bug, it will run properly only for one minute – vikram Jun 23 '16 at 07:38
  • I don't think its a bug, you cant get the email client to keep requesting a refresh of the image from the server without javascript, and the image created has been written to only run for 1 minute. – Russell Young Jun 23 '16 at 07:40
  • So what i can do now, i want it to run for 24 hrs :-), i can change the for loop in that, but it becomes too slow to execute rite? – vikram Jun 23 '16 at 07:42
  • Yes its not practical. This is why you don't see fully working countdown clocks in emails... Why not redirect your users to your website instead, where you can do what you like? – Russell Young Jun 23 '16 at 07:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/115379/discussion-between-russell-and-vikram). – Russell Young Jun 23 '16 at 07:47
  • Also worth noting that animated GIFs don't play in Outlook. You just see the first frame. – Michael Holland Jun 24 '16 at 19:59
0

As Russell says, email clients generally do not support scripting. Maybe one or two do, but the coverage will be very low.

what i want is the countdown timer which will be displaying in the user email.

But... if what you're interested in is a countdown, you can do that in most email clients. If you have a webserver with PHP, here is a tutorial on how to do this. This won't work in Outlook 2007/10/13, but the coverage is pretty good considering it's interactive inside an email.

There are also online tools to accomplish a countdown timer, though I can't personally vouch for those.

Ted Goas
  • 7,051
  • 1
  • 35
  • 42