From 6a63e22a6da08941e3d5caf947692e49b5715963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jockusch?= Date: Fri, 3 May 2019 15:04:21 +0200 Subject: [PATCH] Scoping corrections. Auto-detect correct iframe. --- app/ui.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/ui.js b/app/ui.js index c8472310..6985c9e8 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1168,7 +1168,7 @@ const UI = { * ------v------*/ toggleFullscreen() { - var doc = document; + let doc = document; if (window.self !== window.top) { doc = window.parent.document; } @@ -1186,11 +1186,15 @@ const UI = { doc.msExitFullscreen(); } } else { - var doc_el = document.documentElement; + let doc_el = document.documentElement; if (window.self !== window.top) { - var iframeid = WebUtil.getQueryVar('iframeid', null); - if (iframeid) { - doc_el = window.parent.document.getElementById(iframeid); + let iframes = window.parent.document + .getElementsByTagName('iframe'); + for (let i in iframes) { + if (iframes[i].contentDocument === document) { + doc_el = iframes[i]; + break; + } } } if (doc_el.requestFullscreen) {