Chen Yangjian's Blog

Carpe diem - Seize the day

IE 6、7 中在 Iframe 中操作父窗口 DOM 的时候的问题

| Comments

错误信息:Invalid argument error using AppendChild

具体情况是,在 iframe 中的页面里头,写:

var node = document.createElement('div');
parent.document.body.appendChild(node);

解决办法是,使用父窗口的 document 对象创建 HTMLElement:

var doc = parent.document, node = doc.createElement('div');
doc.appendChild(node);

不过我在 IE6 下还是遇到这个问题,实在搞不懂为神马,暂且压着。

Comments