javascript - Is there a way to have a button in an email remotely send data? -
so have hidden form , 'i this' button insert emails send out.
<form method="post" action="http://somewebsite.com/he_likes_it"> <input type="hidden" name="who_liked" value="helikedit@something.com" /> <input type="submit" value="i this" /> </form>
i can insert button email fine. so, whenever email recipient clicks on button in email, post request form data sent server letting me know liked email. however, clicking on button opens link (new browser window/tab, etc.) directing users site. how prevent clicking of button opening link , send data in form server?
i want button unobtrusive. don't want annoying email recipient having new tab open up. know possible javascript, however, i'm pretty sure email service provider escape javascript in emails should.
for starters, forget javascript -- isn't going happen. no email client allow js through, risky.
as form method, putting aside whether email client lets through, if page closed (see snippet below), some operating systems, browsers, , email clients may play along , "give" focus mail client (which you're after -- user brought "back were"). however, there's no guarantee on how client os, browser, , email client react.
further, people use non-html clients, , clients (like outlook) disallow completely. security perspective, has potential exploit, if you doing not exploitative, entire practice has potential , may blocked.
non-html email clients may dump html text, pretty bad in scenario.
to close window immediately, can try:
<script type="text/javascript">window.close();</script>
so page @ http://somewebsite.com/he_likes_it
consists of output (after doing whatever server-side stuff needs done). depending on browser, , whether other tabs open, , few other factors, window might close without problem. might operative word! user might taken email client. there's no way script this, no way control it.
as alternative, suggest less prone problems , vagaries of email clients, oses, , browsers... , far less "sneaky" -- don't conceal you're doing user. instead of form, include link in email:
like email? let know: <a href="http://www.mysiteurl.com/he_liked_it/unique_identifier">http://www.mysiteurl.com/he_liked_it/unique_identifier</a>
the unique identifier email (which doing in form anyway), or kind of token linked user. in either case, on page can include text thank user feedback:
thanks! we're glad liked email. can close window, or click here go main page.
this cross-browser, cross-os, , work html-enabled email client. plain-text clients, they'll able copy-paste url browser without seeing overt amount of markup clutter. users appreciate transparency, expressed gratitude, , you're not sending them emails set off email client's security warnings.
Comments
Post a Comment