Solved

IE slows down very much with appendChild

Posted on 2008-10-21
3
1,175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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.

735 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