Using css/javascript on email payment block (New Order Email)
-
16-10-2019 - |
Question
I'm developing an payment module that shows a button with an action performed with javascript.
This is the code exibed on frontend:
<p>
<script type="text/javascript">
function someAction(popup) {
var url = 'http://url.com/';
if (popup == true) {
window.open(url, 'new_window', 'toolbar=yes,menubar=yes,resizable=yes,status=no,scrollbars=yes,width=675,height=485');
}
else {
window.location.href = url;
}
}
</script>
<button type="button" class="form-button" target="new_window" onclick="someAction(true)">
<span>Exibir Boleto</span>
</button>
</p>
On frontend (success page, customer page) shows OK and in backend too, but when this block is sent by email, the code sent is:
<td>
<p>Boleto Bancário</p>
<p>
<button type="button">
<span>Exibir Boleto</span>
</button>
</p>
</td>
My question is: What happened to my javascript and part of html properties ?
Solution
You cannot send javascript through e-mails.
I mean...you can but nothing happens. I recommend you to change your button to an a
tag and just have <a href="some/url" target="_blank">...</a>
.
OTHER TIPS
Generally speaking email readers do not allow javascript.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange