Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var webOutput = document.querySelector("[data-acc-text='alt_text']");
- // Paste your HTML Code
- var htmlCode = ``;
- // HTML Code
- function ensureFullDoc(src) {
- var hasHTML = /<\s*html[\s>]/i.test(src);
- if (hasHTML) return src;
- return (
- '<!DOCTYPE html><html lang="en"><head>' +
- '<meta charset="utf-8">' +
- '<meta name="viewport" content="width=device-width,initial-scale=1">' +
- '</head><body>' + src + '</body></html>'
- );
- }
- function renderHTML() {
- if (!webOutput) return;
- var iframe = document.createElement('iframe');
- iframe.style.width = '100%';
- iframe.style.height = '100%';
- iframe.style.border = '0';
- iframe.style.pointerEvents = 'auto';
- iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
- webOutput.innerHTML = '';
- webOutput.appendChild(iframe);
- if ('srcdoc' in iframe) {
- iframe.srcdoc = ensureFullDoc(htmlCode);
- } else {
- var doc = iframe.contentWindow.document;
- doc.open();
- doc.write(ensureFullDoc(htmlCode));
- doc.close();
- }
- }
- renderHTML();
Advertisement
Add Comment
Please, Sign In to add comment