Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

body and head element just disappears when inserted through innerHTML

13 views
Skip to first unread message

bul...@hotmail.com

unread,
Aug 26, 2008, 12:38:02 AM8/26/08
to
Whats going on here?

I tried these on http://www.google.com BTW.

The following line works correctly.

javascript: document.write( "<head><title> Simple document </title> </
head> <body> <div>The text of the document goes here.</div></body>");
void 0;

If I do the following, the body and head elements disappears in the
DOM Inspector. The innerHTML result also has the body and head
missing.

javascript: document.body.parentNode.innerHTML = "<head><title> Simple
document </title> </head> <body> <div>The text of the document goes
here.</div></body>"; void 0;

Here is an example of how the source changes and a different path to
the element (same result tho).

javascript: alert(window.document.documentElement.innerHTML =
"<head><title> Simple document </title> </head> <body> <div>The text
of the document goes here.</div></body>");
alert(window.document.documentElement.innerHTML); void 0;

How can the body and head element just disappear like that? Is this a
bug? Is my code wrong? Is it a bug that innerHTML works on an HTML
element and standards wise its not supposed to?

This was tested on Firefox 2.0.0.16 and 1.5.0.12.

Boris Zbarsky

unread,
Aug 26, 2008, 8:44:46 AM8/26/08
to
bul...@hotmail.com wrote:
> How can the body and head element just disappear like that? Is this a
> bug?

Yes. It's also filed, last I checked.

-Boris

0 new messages