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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy page stalling in IE6 with dynamic table gen via DOM

    hi guys, first post here, wonder if you can help me.

    I am getting a table via php fopen() from another website (with permission) writing it to a hidden div on the page so I can access it via the DOM.

    My script then picks up the table and then parses it picking out the data from the old cells and creating new textNodes and elements to create a new table free of the other page's formatting.

    It works fine in Firefox but in IE6 and safari the page stalls after displaying the banner and main text container.

    page is http://www.loughboroughhockey.co.uk/leagues

    the script is

    Code:
    function getLeagueTable(){
    	if(!document.getElementById('leagueFrame')) {return false;}
    	if(!document.createElement) return false;
    	if(!document.createTextNode) return false;
    	var leagueFrame = document.getElementById('leagueFrame');
    	var outputDiv = document.getElementById('output');
    	
    	var tables = leagueFrame.getElementsByTagName('table');	
    	var leagueTable = tables[0];
    	
    	var newLeagueTable = document.createElement('table');
    	var newTableBody = document.createElement('tbody');
    
    	var oldRows = leagueTable.getElementsByTagName('tr');	
    	
            //ignore first cell in each row because it is empty
    	for (i = 1; i < oldRows.length ; i++){
    		var cells = oldRows[i].getElementsByTagName('td');
    		
    		var newRow = document.createElement('tr');
    				
    		//deal with title cell because the text we want is within an 'a'
    		var aContents = cells[1].getElementsByTagName('a');
    		var teamName = aContents[0].firstChild.nodeValue;
    				
    		var titleCell = document.createElement('td');
    		var newTextNode = document.createTextNode(teamName);
    		
    		titleCell.appendChild(newTextNode);
    		newRow.appendChild(titleCell);
    		
    		//now deal with rest of cells
    		for (j = 2; j < cells.length ; j++){
    			//get value from old cell
    			var oldText = cells[j].firstChild.nodeValue;
    			
    			var currentCell = document.createElement('td');
    			var textNode = document.createTextNode(oldText);
    			
    			currentCell.appendChild(textNode);
    			newRow.appendChild(currentCell);
    		
    		}
    		
    		newTableBody.appendChild(newRow);
    		
    	}
    	
    	
    	newLeagueTable.appendChild(newTableBody);
    	outputDiv.appendChild(newLeagueTable);
    }
    please help!!
    thanks

    Eric

  • #2
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    haha im such a dumbass sometimes. I tracked down the problem thanks to microsoft's dev tools (wonder where they got the idea) and its dom inspector. I had chopped the last ">" off the closing table tag. Firefox was smart enough to put it back in and carry on as normal and the source looked fine, it was only finding some errors in the DOM in IE that let me track down the problem. Nothing to do with the JS in the end.



    Eric


  •  

    Posting Permissions

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