Re: Putting DIV wrapper around all code in body



On Mar 30, 10:02 pm, andrej.kau...@xxxxxxxxx wrote:
I need to put all body content into wrapper when page is loaded. Via
javascript of course.

Initial DOM

<body>
<div>
<p>Some text</p>
<p>More text</p>
</div>
</body>

Modified DOM with javascript

<body>
<div id="myWrapper">
<div>
<p>Some text</p>
<p>More text</p>
</div>
<div>
</body>

Any idea?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en-US">
<head>
<meta http-equiv="Content-type"
content="text/html; charset=iso-8859-1">
<title>Demo</title>
<script type="text/javascript">
function init() {
var elm = document.createElement('DIV');
elm.innerHTML = document.body.innerHTML;
document.body.innerHTML = '';
document.body.appendChild(elm);
}
window.onload = init;
</script>
</head>
<body>
<p>Page content</p>
</body>
</html>
.



Relevant Pages

  • Putting DIV wrapper around all code in body
    ... I need to put all body content into wrapper when page is loaded. ... Modified DOM with javascript ...
    (comp.lang.javascript)
  • passing parameter problems
    ... I'm designing a website in dreamweaver and I'm using JavaScript to ... The text is contained in <div> tags. ... The following set up works fine, calling moveParas which moves two div ...
    (comp.lang.javascript)
  • Re: Hide/Show Selection List
    ... A div is a BLOCK element, meaning that is rectangle with some content. ... a SPAN is an inline element, eg a part of a sentence. ... For span you should use inline. ... you are using a suspect/bad way to invoke a javascript function. ...
    (comp.lang.javascript)
  • Re: viewable coordinates of an element
    ... javascript and web design as a whole, ... Is there a way to like when i scroll the DIV to this element, ...
    (comp.lang.javascript)
  • cant set mouse cursor
    ... I'm writing a panoramic image viewer in javascript. ... (which covers the same area as the div), ... The html is ...
    (comp.infosystems.www.authoring.stylesheets)