0

I have a bookmarklet storing a lot of DOM data, but I would love to avoid to put them out of the body tag so the script in the page won't mess with it.

Semantic value is not an issue for once, but I would like to know :

  • will it trigger some browser behaviour ?
  • will it still be accessible in the DOM ?
  • can I display it using absolute positionning or should I move it to the body every time ?
Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
Bite code
  • 578,959
  • 113
  • 301
  • 329

2 Answers2

4

Everything inside the <html> tag (even if outside the <body> tag) can be accessed via document.documentElement.

Eli Grey
  • 35,104
  • 14
  • 75
  • 93
  • Great. But can it be displayed using absolute positiong, or will it result with unpredictable behaviors accross browsers. I am asking before testing because I am on a linux machine and for now, can't test in 10 different browsers to check. – Bite code Oct 10 '09 at 15:17
  • 4
    If you're not producing a valid document, then behaviour across browsers is by definition undefined. Best to find a solution that's valid – Gareth Oct 10 '09 at 15:22
0

Result of some little testing :

  • Firefox won't display a big red DIV if it's after </body>
  • Firefox won't run alert() from a SCRIPT if it's after </body>
  • Firebug don't see them but display the famous Firebug DIV after </body>
Bite code
  • 578,959
  • 113
  • 301
  • 329