Add polyfill for browsers not supporting srcdoc
This commit is contained in:
parent
efaf6fd444
commit
d745f98bb7
|
@ -1,8 +1,18 @@
|
||||||
var emailFrame = document.getElementById("email-frame");
|
var emailFrame = document.getElementById("email-frame");
|
||||||
if (emailFrame) {
|
if (emailFrame) {
|
||||||
|
// Resize the frame with its content
|
||||||
var resizeFrame = function() {
|
var resizeFrame = function() {
|
||||||
emailFrame.style.height = emailFrame.contentWindow.document.documentElement.scrollHeight + "px";
|
emailFrame.style.height = emailFrame.contentWindow.document.documentElement.scrollHeight + "px";
|
||||||
};
|
};
|
||||||
emailFrame.addEventListener("load", resizeFrame);
|
emailFrame.addEventListener("load", resizeFrame);
|
||||||
emailFrame.contentWindow.addEventListener("resize", resizeFrame);
|
emailFrame.contentWindow.addEventListener("resize", resizeFrame);
|
||||||
|
|
||||||
|
// Polyfill in case the srcdoc attribute isn't supported
|
||||||
|
if (!emailFrame.srcdoc) {
|
||||||
|
var srcdoc = emailFrame.getAttribute("srcdoc");
|
||||||
|
var doc = emailFrame.contentWindow.document;
|
||||||
|
doc.open();
|
||||||
|
doc.write(srcdoc);
|
||||||
|
doc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,6 @@
|
||||||
{{if .Body}}
|
{{if .Body}}
|
||||||
<p><a href="{{.Message.Uid}}/reply?part={{.PartPath}}">Reply</a></p>
|
<p><a href="{{.Message.Uid}}/reply?part={{.PartPath}}">Reply</a></p>
|
||||||
{{if .IsHTML}}
|
{{if .IsHTML}}
|
||||||
<!-- TODO: add a src fallback -->
|
|
||||||
<!-- allow-same-origin is required to resize the frame with its content -->
|
<!-- allow-same-origin is required to resize the frame with its content -->
|
||||||
<!-- allow-popups is required for target="_blank" links -->
|
<!-- allow-popups is required for target="_blank" links -->
|
||||||
<iframe id="email-frame" srcdoc="{{.Body}}" sandbox="allow-same-origin allow-popups"></iframe>
|
<iframe id="email-frame" srcdoc="{{.Body}}" sandbox="allow-same-origin allow-popups"></iframe>
|
||||||
|
|
Loading…
Reference in a new issue