Solved

IE slows down very much with appendChild

Posted on 2008-10-21
3
1,147 Views
Last Modified: 2013-12-08
Below is shown the code that is causing problems. It is related to other parts of code, together which they create a list that is to be added to current page to the span-tag with id "lista".
With Fireworks, everyting works OK and with reasonable good speed. However, with Internet explorer (7 and I guess also earlier versions) it will run smoothly and also with reasonable speed until the line
container.appendChild(newdiv);
is reached (tested with the aler above, and also by commenting that line). However, runnign that line causes the page to load v e r y slowly and when refreshed or reloaded after visiting other parts of site, the mentioned error dialog is shown (script slowing IE down).
Is there some other way to put the code in http.responseText; to the existing page? That http.resonseText holds long list in table, inside a div -tag.

function lataaListat()

{

	try

		{

			if (http.readyState == 4){

				if (http.status == 200)

				{

					if (http.responseText)

					{

						var newdiv = document.createElement("div");

						newdiv.innerHTML = http.responseText;

						var container = document.getElementById("lista");

						alert ("valmis");

						container.appendChild(newdiv);

					}

					else

					{

						alert("http.responseXML ei skulaa");

					} 

				}

				else if(http.status == 404) {

					alert("Requested file not found");

				}

				else {

					alert("Error has occurred with status code:"+http.status);

				} 

			}

		}

		catch (err)

		{

			alert(err.description);

			alert("Haku ei onnistunut");

		}

}

Open in new window

0
Comment
Question by:Seppoo
  • 2
3 Comments
 

Author Comment

by:Seppoo
Comment Utility
I don't know if these findings help further, but:
I figured out that all goes fine if I change what I am appending there. If I append:the code below, all goes fine ( I actually do abbed a little more, but since that causes no problem and it would just take space here I have excluded that. However that excluded part contains table inside of form, which would be appended just before this div-tag).

However, if I append lot of table rows instead of these 2 testlines here, the problems appear.

Moreover, I realized that refreshing the IE did not sho me the immedeate changes I had made while testin, I had to close- reopen whole IE to see the results.
Also, it seemed that the first time I go to the page where this long list loads up, it is OK, However if I go to some other page on same site and then pack there again (in the link "Tuoteluettelo), I get the error of script slowing IE down.
All these act differently in FF: I can reload the page seeing changes without closing FF. And I can navigate freely and come back without any lack of speed.
Therefore, it seems that IE somehow does keep the script running and cant stop it, when it has many lines. Anyway, this all seems odd behaviour..

The link to the site and problem page is here:
http://www.siistii.com/turbotekniikka/index.php?option=com_content&view=article&id=152&Itemid=56



<div style="align:center; height:400px; overflow:auto;">

  <table>

    <tbody>

      <tr>

        <td>testline1</td>

      </tr>

      <tr>

        <td>testline2</td>

      </tr>

    </tbody>

  </table>

</div>

Open in new window

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
Comment Utility
Did you try to have an empty div already in the document and just do

if (http.responseText) {
  document.getElementById('existingDiv').innerHTML = http.responseText;
}


???

0
 

Author Closing Comment

by:Seppoo
Comment Utility
I am not sure how I managed to make things work actually, it's been a while :) I just forgot this question open, so this is mainly just closing it - and you got the points for 2 reasons: I think that your solution was somewhat similar that I ended up using, and then, your answer was the only one :) Thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now