Wrap email content in email detail view in an iframe to avoid leakage of styles
</tr>
<tr>
<th>{% trans 'Body' %}</th>
- <td>{{ email.body_html|safe }}</td>
+ <td>
+ <iframe id="preview_box" width="100%" height="400">{{ email.body_html|safe }}</iframe>
+ </td>
</tr>
</table>
{% endblock tabcontent %}
+
+{% block onbodyload %}
+ {{ block.super }}
+
+ $(function() {
+ // Sets the HTML email preview so it's css doesn't touch the page.
+ var el_preview_html = document.getElementById('preview_box');
+ var html = $(el_preview_html).text();
+ var doc = el_preview_html.contentWindow.document;
+ doc.open();
+ doc.write(html);
+ doc.close();
+ });
+
+{% endblock %}
