So, I was trying to make HTML appear at the click of a button, but instead of inserting the HTML right where the script tag was, the entire page was overwritten with the code that was supposed to be generated. After experimenting, I found that something simple like
document.write("<p>" + "Hello!" + "</p>")
would simply insert it as it should. On the other hand, the code I was trying to do replaced the entire page.
Does anyone know how to fix this? Here is some example code.
function writeIFrame() {
document.write('<iframe width="500" height="300" src="https://www.youtube.com/embed/UJFdywQqovI" frameborder="0" allowfullscreen></iframe><p>Check out my YouTube channel <a href="https://www.youtube.com/channel/UCkqJM5HVjuvPA9H1VuFU5pQ">here</a> and subscribe!');
}