29 lines
981 B
JavaScript
29 lines
981 B
JavaScript
document.addEventListener('DOMContentLoaded', documentReady, false);
|
|
|
|
function documentReady() {
|
|
const iframe = document.querySelector("iframe");
|
|
const dialog = document.querySelector("dialog");
|
|
iframe.onload = (event) => {
|
|
dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px";
|
|
if (event.target.contentWindow.location.search.includes("submitted")) {
|
|
dialog.close();
|
|
window.location.href=window.location.href
|
|
}
|
|
}
|
|
}
|
|
|
|
window.onmessage = (event) => {
|
|
if (event.data == "close") {
|
|
const dialog = document.querySelector("dialog[open]");
|
|
const iframe = document.querySelector("iframe");
|
|
dialog.close();
|
|
iframe.src = "about:blank"
|
|
}
|
|
}
|
|
|
|
function onOpenDialog(href) {
|
|
const iframe = document.querySelector("iframe");
|
|
const dialog = document.querySelector("dialog");
|
|
iframe.contentWindow.location = href;
|
|
dialog.showModal();
|
|
} |