I want to load/append the iframe into a div with regular javascript. I can do this with JQuery without a problem, but I dont want to include the js file. I keep getting the error 'document.getElementById("ad54")' (or whatever id I assign the div). I have the following code:
var link = "http://www.google.com"
var iframe = document.createElement('iframe');
iframe.frameBorder=0;
iframe.width="300px";
iframe.height="250px";
iframe.id="randomid";
iframe.setAttribute("src", link);
document.getElementById("ad54").appendChild(iframe);
<div id="ad54"></div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…