Gallery-type website update: problem in scrollLeft function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phrnck
    New Member
    • Aug 2006
    • 2

    Gallery-type website update: problem in scrollLeft function

    Hey all,

    I'm updating and adapting a gallery-type website that was done in FrontPage, in an old version. I've gotten most of it to work in modern browsers, but am stuck on one function... I am hoping someone can take a look and see where my trip-up lies. I've included just a snip from the html - where the debugger stops, thinking the problem is in the external js.

    Thanks in advance for any guidance!! Really stuck on this!!

    here is the event handler from the html page:

    Code:
     ...
    <script type="text/javascript" src="thumbs/sldshow5.js"></script>
        
                    <div id="galleryLeftBtn">
                    <img src="thumbs/prev.gif" onClick="JavaScript:scrollLeft()" alt="left arrow" title="previous image">
                    <p>previous</p>
                    </div>
     ...
    And here is the problematic function:

    Code:
    ...
    function scrollLeft() 
    {
    	var el = document.getElementById("galleryListCell");
    	if (el) 
    	{
    		var coll = el.getElementsByTagName("a");
    		var count = 20;
    
    		if (coll) 
    		{
    			for (i=1;i<coll.length;i++) 
    			{
    				if (coll[i].style.display != "none") 
    				{
    					coll[i-1].style.display = "inline";
    					break;	
    				}
    			}
    			
    			for (i=0;i<coll.length;i++) 
    			{
    				if (coll[i].style.display != "none") 
    				{
    					var images = coll[i].getElementsByTagName("img");
    					count = count + 20 + images[0].width;
    					
    					if (count > widthLength)
    					{
    						coll[i].style.display = "none";
    					}
    				}
    			}
    
    			if ((el.scrollWidth - 4) >= el.clientWidth) 
    			{
    				var btn = document.getElementById("galleryRightBtn");
    				if (btn && rightdisabled) 
    				{
    					rightdisabled = false;
    				}
    			}
    			
    			if (coll[0].style.display != "none") 
    			{
    				var btn = document.getElementById("galleryLeftBtn");
    				if (btn && !leftdisabled) 
    				{
    					leftdisabled = true;
    				}
    			}
    		}
    	}
    }
    ...
    Here is a URL to see the whole offending page, if needed:


    Thanks for any and all advice!!!!!!!
    phrnck
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    May be some other problem elsewhere. The first thing to check is the error console for errors in a decent browser.

    Comment

    Working...