Replacing document.write

Hi, how can I replace document.write in this code?

<script type="text/javascript">
var x = 1;
document.write(unescape("%3Cscript src='https://www.domain.com/iframe.php' type='text/javascript'%3E%3C/script%3E"));
</script>

Hi @skyline, you can create a script element, set its src property and then append it to the document like so:

var script = document.createElement('script')

srcipt.src = 'https://www.domain.com/iframe.php'
document.body.appendChild(script)
1 Like

Great, thanks!

1 Like