markdown: allow-same-origin sandbox iframe

This commit is contained in:
Steven Hugg 2020-07-11 23:18:37 -05:00
parent 52d6f69d09
commit 9b7df7938a
1 changed files with 2 additions and 10 deletions

View File

@ -9,8 +9,7 @@ class MarkdownPlatform implements Platform {
constructor(mainElement:HTMLElement) {
this.mainElement = mainElement;
this.iframe = $('<iframe sandbox seamless src="javascript:void(0);" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
//this.iframe = $('<iframe sandbox src="res/markdown-iframe.html" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
this.iframe = $('<iframe sandbox="allow-same-origin" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
this.iframe.style.backgroundColor = 'white';
mainElement.classList.add("vertical-scroll"); //100% height
mainElement.style.overflowY = 'auto';
@ -24,14 +23,7 @@ class MarkdownPlatform implements Platform {
resume() {
}
loadROM(title, data:string) {
// have to do this b/c sandboxed without same origin
// TODO: preserve scroll position
if (this.iframe.srcdoc)
this.iframe.srcdoc = data;
else
this.iframe.src = "data:text/html;charset=utf-8," + escape(data);
//this.iframe.contentWindow.postMessage({body:data}, "*");
//$(this.iframe).contents().find('body').html(data);
$(this.iframe).contents().find('body').html(data);
}
isRunning() {
return false;