Created
May 7, 2020 21:24
-
-
Save confraria/094c3d09e246b70e7ccaf73bc2c47222 to your computer and use it in GitHub Desktop.
aaa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iFrameFix(aId, divId) { | |
const $a = document.getElementById(aId); | |
const $div = document.getElementById(divId); | |
const renderIframe = (img = {}) => { | |
const w = img.naturalWidth || 100; | |
const h = img.naturalHeight || 100; | |
$div.innerHTML = `<iframe src="${a.href}" frameborder=0 width="${w}" height="${h}"></iframe>`; | |
}; | |
if ($a !== null && $div !== null) { | |
let img = div.querySelector("img"); | |
if (img) { | |
if (img.complete) { | |
renderIframe(img); | |
} else { | |
img.addEventListener("load", () => renderIframe(img)); | |
} | |
} else { | |
renderIframe(); | |
} | |
} | |
} | |
iframeFix("iframe_A", "iframe_DIV"); | |
iframeFix("iframeLink", "iframeDiv"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment