document.write in prebid.js
Type of issue
feature request
Description
We need to get rid of all document.write over our pages, but there is one laying within prebid.js. It seems to only relates to native ads, but still, it's fairly easy to avoid this.
Steps to reproduce
module: exports.insertHtmlIntoIframe
exports.insertElement(iframe, document, 'body');
iframe.contentWindow.document.open(); iframe.contentWindow.document.write(htmlCode); iframe.contentWindow.document.close();
Could be possibly be as easy as: iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(htmlCode);
@sgagnierH Have you tested this in IE 11, Safari 9+ and Edge ?
The code you posted is not equivalent unfortunately. The document.write method importantly preserves the DOM of the existing document (if it's already open) before writing content vs setting the iframe src will destroy any other content.
@jaiminpanchal27 No I did not tested it, it's a kinda hint.
@mkendall07 If you look at the code in place, you'll see that it creates the iframe just before the document.write, so there's nothing in it to be lost.
cool, in that case it's ok as long as it's proven to work in the target browsers (modern + ie11 )
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.