Remove Iframe (force garbage collection

Date: 2019-02-04

Force unbind of all eventlisteners by loading a new empty document and waiting for it to be loaded

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function removeIframe(frame, cb) {
var emptyHtmlPage = "data:text/html;charset=utf-8;base64,PGh0bWw+PGJvZHk+PC9ib2R5PjwvaHRtbD4=";
frame.setAttribute("src", emptyHtmlPage);
frame.addEventListener("load", function() {
frame.parentElement.removeChild(frame);
if (cb) {
cb();
}
});
}
function removeIframe(frame, cb) { var emptyHtmlPage = "data:text/html;charset=utf-8;base64,PGh0bWw+PGJvZHk+PC9ib2R5PjwvaHRtbD4="; frame.setAttribute("src", emptyHtmlPage); frame.addEventListener("load", function() { frame.parentElement.removeChild(frame); if (cb) { cb(); } }); }
function removeIframe(frame, cb) {
  var emptyHtmlPage = "data:text/html;charset=utf-8;base64,PGh0bWw+PGJvZHk+PC9ib2R5PjwvaHRtbD4=";
  frame.setAttribute("src", emptyHtmlPage);
  frame.addEventListener("load", function() {
    frame.parentElement.removeChild(frame);
    if (cb) {
        cb();
    }
  });
}
18470cookie-checkRemove Iframe (force garbage collection
0 of 2000 max characters.