我想將iframe元素添加到頁面中,然後在該iframe內添加<p>
元素。
我嘗試這樣做:動態添加iframe和段落元素
var iframe = document.createElement('iframe');
iframe.frameBorder = 1;
iframe.width = "500px";
iframe.height = "250px";
iframe.id = "iframe";
var p = document.createElement('p');
iframe.appendChild(p);
document.getElementById("div").appendChild(iframe); //this is a div that I have in body.
iframe的被添加到頁面,但P不加入的iframe(iframe的身體)
div是div元素的正確ID屬性嗎? – karim79 2010-06-05 22:53:48
當然,iframe添加了但P不是 – shivesh 2010-06-05 22:56:23