?
Solved

IE slows down very much with appendChild

Posted on 2008-10-21
3
Medium Priority
?
1,231 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
ID: 22771603
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 1500 total points
ID: 22773938
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
ID: 31508349
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

571 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