473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Putting DIV wrapper around all code in body

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?
Mar 30 '08 #1
3 1454
Guys, thanks a lot.
It really solved my problem. I was trying approach with "appendChild"
but totaly forgot that when first child is moved into div than next
child is now firstChild :-). I will test this solution with innerHTML
also to compare speeds.
Thanks a lot.
Mar 31 '08 #2
George Maicovschi wrote:
From personal experience I know that moving a LOT of elements (or
creating a LOT of new ones) can cause the browser to move slowly and
make a user experience not so nice, so this method shouldn't be used
on very large pages.

Couldn't we try an approach using the innerHTML? :-/
In any case browser need to remove all elements from body and insert
them to DIV, but in the case of innerHTML here is additional conversion
from DOM to HTML (text=body.innerHTML) and then back from HTML to DOM
(div.innerHTML=text) so I don't think it's more fast then direct moving.
Mar 31 '08 #3
On Mar 31, 10:16 am, andrej.kau...@gmail.com wrote:
Guys, thanks a lot.
It really solved my problem. I was trying approach with "appendChild"
but totaly forgot that when first child is moved into div than next
child is now firstChild :-). I will test this solution with innerHTML
also to compare speeds.
Thanks a lot.
Hey Andrej, just post here your conclusions about the speed of the two
methods, I'm quite curious about them results on your script, since I
am using innerHTML now for something similar because when using
appendChild on a high number of elements in Firefox the memory
requests of Firefox just went up a whole lot.

Regards,
George Maicovschi.
Mar 31 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: dedejavu | last post by:
Hi all you JS experts, Is there any way to put a blinking ibeam cursor in middle of td text - the same way it would blink if I clicked in the middle of the text in a text input? To further...
15
by: Steve Richfield | last post by:
To All, First, some of your replies to me have been posted through DevelopersDex, and these are NOT posted on USENET for the world to see. DevelopersDex appears to be trying to hijack USENET,...
0
by: DotNetJunkies User | last post by:
Background: I am creating a VC++ .NET wrapper for a C++ DLL; the aim is to use this wrapper in C# as shown below: Range r = new Range( 2, 2 ); r = new Cell( “Hello Mum” ); Range is a...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
2
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 ...
3
by: markww | last post by:
Hi, I have a wrapper around some 3rd party database library function. The pseudo code looks like the following - it is meant to open a table in a database, extract values from a table, then copy...
16
by: utab | last post by:
Dear all, In programming terminology, what is a wrapper and where is it used? Regards
9
by: ma740988 | last post by:
Assume I have a vendor file called ' vendor.h'. Within the file there's two methods memalign and cforward. It is my understanding that the memalign function is a wrapper around malloc. cforward...
4
by: Doug Laidlaw | last post by:
Thank you everybody for your help to date, and please be tolerant of a CSS beginner! I have successfully converted my site at http://www.douglaidlaw.net/boykett/ to use a free 3-column template...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.