SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Script stops other scripts from loading

    hi
    I am using a little script to swap CSS classes when a certain character is found in the title of links. I also use an eventlistener to load the script at onload. Now, it seems that this script stops the loading of other scripts, for instance my Google Analytics tracker (Warning: Unresponsive script).
    The script runs on http://www.wideopenwin.com, but till this has resolved I have commented out the addLoadListener...

    Here is the script:

    Code:
    function swap(){ 
    	for(i=0; (plink= document.getElementById('parents').getElementsByTagName("a")[i]); i++) 
    	for(i=0; (clink= document.getElementById('children').getElementsByTagName("a")[i]); i++) 
    	for(i=0; (jlink= document.getElementById('jumps').getElementsByTagName("a")[i]); i++) 
    	{
         	        pt=plink.getAttribute('title')
    		ct=clink.getAttribute('title')
    		jt=jlink.getAttribute('title')
         	        if (pt.indexOf('@') !=-1){plink.className='arrow'}
    		if (ct.indexOf('@') !=-1){clink.className='arrow'}
    		if (jt.indexOf('@') !=-1){jlink.className='arrow'}
    	}
    }
    addLoadListener(swap);
    </script>
    Does anybody know why?

  2. #2
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found it! The script is way to complicated. All that is needed is

    Code:
    function swap(){ 
    	for(i=0; (links = document.getElementsByTagName("a")[i]); i++)  {
         	link_title=links.getAttribute('title')
         	if (link_title.indexOf('@') !=-1){links.className='arrow'}
    	}
    }


Bookmarks

Posting Permissions

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