开发者

How to refer to the true 'body' of a page? [NOT iFrame body]

I have a script that create a new div element. Then, I want to append the div to the body of the page using appendChild method.

The script is look like this :

var div = document.createElement('div');
div.id = 'newdiv';
document.body.appendChild(div);

Unfortunately, the div also appended to the body of iframes. So, my question is, how to refer to the true body of the document, not including the body of the iframes? That way, the div just appended once, to the "true body" of the document. Thanks before, and sorry if my english is bad. :-D

EDIT:

This happens at Mozilla Firefox browser. I haven't tested it at any other browsers yet. And another information, this is a Gre开发者_Python百科aseMonkey script I try to develop.


top.document.body.appendChild(div); //maybe?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜