bodyにいると思ったらheadにいた

<p id="hoge"></p>
<script>document.write(document.getElementById('hoge'))</script>

こういうの。
結果

# IE6
null
# Firefox2
null

自分的には、pタグが出現した時点でそれ以降がbody要素になると思っていたのですが、そうではなくDOM Treeを見たところ以下のように解釈されているようです。

<head>
  <script>document.write(document.getElementById('hoge'))</script>
</head>
<body>
  <p id="hoge"></p>
</body>

えー?そうなん?
順番変わってるやん。



もちろんbody要素を明示すると、

<body>
  <p id="hoge"></p>
  <script>document.write(document.getElementById('hoge'))</script>
</body>
# Firefox2
[object HTMLParagraphElement]
# IE6
[object]

となります。へぇー。