【发布时间】:2011-05-31 06:24:23
【问题描述】:
我已经动态创建了一个 iframe 并为其添加了 src 属性。然后我将此 iframe 附加到页面的正文中。知道我想将onload 事件附加到 iframe 以读取 iframe 内容。有人可以建议我该怎么做吗?
frame = document.createElement('iframe');
frame.setAttribute('src','http://example.com');
body.appendChild(frame);
frame.onload = function(){
alert('hi'); // here I want to read the content in the frame.
}
【问题讨论】:
标签: javascript iframe dom-events