function setupIframe() { var iframe = document.querySelector('iframe'); var html = "
"; if (iframe.className === "limited-quirks") { html = '' + html; } else if (iframe.className === "no-quirks") { html = '' + html; } window.quirks = iframe.className === "quirks"; window.win = iframe.contentWindow; win.document.open(); win.document.write(html); win.document.close(); ['style', 'test', 'ref', 'svg', 'svg_ref'].forEach(function(id) { win[id] = win.document.getElementById(id); }); }