Scoping corrections. Auto-detect correct iframe.

This commit is contained in:
Ján Jockusch 2019-05-03 15:04:21 +02:00
parent 3e1bf5fce9
commit 6a63e22a6d
1 changed files with 9 additions and 5 deletions

View File

@ -1168,7 +1168,7 @@ const UI = {
* ------v------*/ * ------v------*/
toggleFullscreen() { toggleFullscreen() {
var doc = document; let doc = document;
if (window.self !== window.top) { if (window.self !== window.top) {
doc = window.parent.document; doc = window.parent.document;
} }
@ -1186,11 +1186,15 @@ const UI = {
doc.msExitFullscreen(); doc.msExitFullscreen();
} }
} else { } else {
var doc_el = document.documentElement; let doc_el = document.documentElement;
if (window.self !== window.top) { if (window.self !== window.top) {
var iframeid = WebUtil.getQueryVar('iframeid', null); let iframes = window.parent.document
if (iframeid) { .getElementsByTagName('iframe');
doc_el = window.parent.document.getElementById(iframeid); for (let i in iframes) {
if (iframes[i].contentDocument === document) {
doc_el = iframes[i];
break;
}
} }
} }
if (doc_el.requestFullscreen) { if (doc_el.requestFullscreen) {