javascript - Wrapping a div around the document body -


I am trying to dynamically wrap the body tags of a document in a DIV. Up to now, I have used the following code:

  document.body.innerHTML = '& lt; Div id = "wrap" & gt; + Document.body.inner HTML + '& lt; / Div & gt; ';  

This works, but there is an unwanted side effect that the other script is working on the same page (I believe because any object referencing the internal HTML is useless Can).

What will be the best / most effective way to achieve and retain references using a pure javascript or prototype framework

Thanks in advance!

You do something like this:

  var div = document .createElement ("div"); Div.id = "wrap"; // Move the body of the body to this cover, while (document.body.firstChild) {div.appendChild (document.body.firstChild); } // Add the ring to the body document. Don.appendChild (div);  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -