Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    IE getting bogged down

    I'm writing a task manager application and in FF and Opera its perfect, completely stable, no problems with it at all - no matter how fast I click around but in IE, even with just normal- moderately fast use, it bogs down and eventually IE hangs in just a couple of minutes usage - seconds if you click around really fast.
    I'm no js wizz but I know there must be a way around this problem - I just cant seem to find it.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
       <head> 
          <title>Icelolly.com Task Management</title>
          <style type = "text/css">
          <!--
          @import "taskmanager.css";
          -->
          </style>
          <script type = "text/javascript">
          <!--
          onload = function()
          {
    	    try
    	    {
    		  xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
    
    		}
    		catch(e)
    		{
    		  //do stuff
    		  try
    		  {
    		    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    		  }
    		  catch(e2)
    		  {
    		    ///argh no ajax - fall over
    		  }
    		}
    			user = 6;
    		  	activetab = 1;
    		  	message = 0;
    		  	orderby = "Date";
    		  	registerEvents(); 
    	  }
    	  
    	  function registerEvents()
    	  {
    	    if(document.getElementById)
    	    {
    		  tabRoot = document.getElementById("tab");
    		  for(i=0; i<tabRoot.childNodes.length; i++)
    		  {
    		    node = tabRoot.childNodes[i];
    		    if(node.nodeName=="LI")
    		    {
    		      node.className = node.id == activetab ? "active" : "";
    		      try
    		      {
    			    result = node.addEventListener ? node.addEventListener('click', changeTab, false) : node.attachEvent('onclick', changeTab);
    			    
    			  }
    			  catch(e)
    			  {
    			    alert("couldnt assign event "+ e);
    			  }
    			}
    		  }
    		  
    		  listRoot = document.getElementById("list");
    		  for(i=0; i<listRoot.childNodes.length; i++)
    		  {
    		    node = listRoot.childNodes[i];
    		    for(j = 0; j < node.childNodes.length; j++)
    		    {
    		      row = node.childNodes[j];
    			  if(row.nodeName == "TR")
    			  {
    			    row.className = row.id == message ? "active" : "";
    			    try
    			    {
    				  result = row.addEventListener ? row.addEventListener('click', changeMessage, true) : row.attachEvent('onclick', changeMessage);
    
    				}
    				catch(e)
    				{
    				  alert("couldnt assign event " +e);
    				}
    			  }
    			}
    		    
    		  }
    		  
    		  orderRoot = document.getElementById("headers")
    		  {
    		    orderRoot = orderRoot.childNodes[0].childNodes[0].childNodes[0];
    		    {
    			  for(i=0; i < orderRoot.childNodes.length; i++)
    			  {
    			    node = orderRoot.childNodes[i];
    			    if(node.nodeName == "TD")
    			    {
    				  node.className = node.innerHTML == orderby ? "orderby" : "";
    				  try
    				  {
    				    result = node.addEventListener ? node.addEventListener('click', changeOrder, false) : node.attachEvent('onclick', changeOrder);
    				  }
    				  catch(e)
    				  {
    				    alert("couldnt assign event "+e);
    				  }
    				}
    			  }
    			}
    		  }
    		}
    	  }
          
          function changeTab(e)
          {
    	    activetab = e['target'] ? e['target']['id'] : window.event.srcElement.id;
    	    target = "listPane";
    	    if(activetab==4)
    	    {
    		  action = 'new';
    		  document.getElementById('messagePane').style.display = 'none';
    		   document.getElementById('headers').style.display = 'none';
    		}
    		else
    		{
    		  action = 'list';
    		  document.getElementById('messagePane').innerHTML = '';
    		  document.getElementById('headers').style.display = 'block';
    		}
    		  if(activetab==5)
    		  {
    		    action = 'all';
    		  }
    		
       
    	    
    		loadURL('proctaskmanager.php', 'tab='+activetab+'&user='+user+'&action='+action+'&message='+message+'&orderby='+orderby);    
    	  }
    	  
    	  function changeMessage(e)
    	  {
    	    message = e.target ? e.target.parentNode.id : window.event.srcElement.parentNode.id;
    	    target = "messagePane";
    	    document.getElementById('messagePane').style.display = 'block';
    	    loadURL('proctaskmanager.php', 'tab='+activetab+'&user='+user+'&action=message&message='+message+'&orderby='+orderby);
    	  }
    	  
    	  function changeOrder(e)
    	  {
    	    orderby = e.target ? e.target.innerHTML : window.event.srcElement.innerHTML;
    	    target = "listPane";
    	    action = 'list';
    	    if(activetab==4)
    	    {
    		  action = 'new';
    		}
    		else if(activetab==5)
    		{
    		  action = 'all';
    		}
    
    	    loadURL('proctaskmanager.php', 'tab='+activetab+'&user='+user+'&action='+action+'&message='+message+'&orderby='+orderby);
    	  }
    	  
           
          function loadURL(url, args)
    		{
    		  xmlhttp.open("GET", url+"?"+args);
    		  xmlhttp.onreadystatechange = handleResponse;
    		  xmlhttp.send(null);
    		}
    		
    		function handleResponse()
    		{
    		  if(xmlhttp.readyState == 4 &&xmlhttp.status ==200)
    		  {
    			if(document.getElementById(target).innerHTML = xmlhttp.responseText)
    			{
    			  registerEvents();
    			}			
    		  }
    		}		
          -->
          </script>
       </head>
       <body>
    	<ul id = "tab"><li class = "active" id = "1">Incomplete</li><li id = "2">Active</li><li id = "3">Complete</li><li id = "4">New</li><li id = "5">Show All Tasks</li></ul>
    
    	<div id = "headers"><table width = "95%"><tr><td width = "15%">Date</td><td width = "70%">Subject</td><td width = "10%">From</td><td width = "10%">Priority</td></tr></table></div>
    	<div id = "listPane"><table width = "95%" id = "list"><tr id = "2"><td width = "15%">00/00/0000 00:00</td><td width = "70%">Test Message 1</td><td width = "10%">Bilbo Baggins</td><td width = "10%">Low</td></tr>
    
    <tr class = "active" id = "1"><td width = "15%">12/05/2006 14:40</td><td width = "70%">Test Message 1</td><td width = "10%">Joanne Bloggs</td><td width = "10%">None</td></tr>
    
    </table></div>
    	<div id = "messagePane"><div class = "messageheader"><strong>From:</strong> Jo Bloggs <strong> at </strong>12/05/2006 14:40 <strong>Priority</strong> None<br />
      <strong>Subject: </strong>Test Message 1</div>
    
      <p class = "message">This is a test message</p></div>
    	
       </body>
    </html>

  • #2
    Banned
    Join Date
    Oct 2005
    Location
    I'm in GMT -5
    Posts
    314
    Thanks
    0
    Thanked 1 Time in 1 Post
    I think you need the "true" to make it asynchonous.

    Code:
    xmlhttp.open("GET", url+"?"+args, true);

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    thats fixed it - cheers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •