My code so far:
var iframe = document.createElement('iframe');
var html = '<style>.alert {padding: 20px;background-color: blue;color: white;}</style><div class="alert">test</div>';
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
My problem is that I want to put this Alert BEFORE my current HTML structure. I know append is obviously putting it AFTER, but is there a workaround or some other method to move it so it's before?
EDIT: the implemented iFrame (generated through JS) is disappearing after 1-2 seconds: Reason??