Solved

IE slows down very much with appendChild

Posted on 2008-10-21
3
1,183 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send parameters via datatable ajax call 4 43
Javascript question 8 43
Form submit takes only for one form 23 51
Migrate all my users to Chrome instead of IE 11 1 32
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
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)
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Suggested Courses

737 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