• User

    Javascript Vertical Image Scroller

    Ciao a tutti gente...

    Sono incasinato con javascript...
    Io voglio creare un auto scorrimento di immagini (slideshow) dentro una tabella all'interno del mio sito...
    Adesso io ho fatto delle ricerche e ho trovato una svarieta' di codice bello epronto da inserire dove mi pare nella mia pagina,,,
    ma pultroppo ogni codice che ho analizato per qualche motivo non rientrava nelle mie esigenze...
    soltanto uno che e' esattamente cio' che cerco...
    ma pultroppo non so per quale motivo non mi funge.... 😞

    Vorrei postare il codice cosi qualcuno magari (gentilmente) mi faccia capire dove vi e' qualche possibile errore...

    PS: Tutto il codice sta dentro una tabella posizionata in basso a sinistra sotto il mio DHTML menu'...

    <style TYPE="text/css">
    	<!--
    	.TextScrollStyle &#123;
    		visibility:hidden;
    		font-family&#58;Verdana;
    		font-weight&#58;bold;
    		text-align&#58;center;
    		padding&#58;0;
    		margin&#58;0;
    		width&#58;150;
    		overflow&#58;hidden;
    	&#125;
    
    	-->
    	</style>
    <script type="text/javascript" language="JavaScript">
    <!-- 
    // Use Freely as long as following disclaimer is intact &#58;&#58;
    //---------------------------------------------------------------
    // Cross Browser Multi-Directional Scroller v1.1 18th January 2005
    // This script written by Rik Comery. www.ricom.co.uk
    // For support, visit the "Resources" section at www.ricom.co.uk           
    // All rights reserved.   
                                         
    Article = new Array;
    i=0;
    
    /* DEFINE SCROLLER ELEMENTS
      Define new scroller elements here in the following format.
      Article&#91;i&#93; = new Array &#40;"display text", "URL", "frame target to load link in"&#41;;i++  
      Note&#58; If you do not want the item to be a link, change the URL value to "none".
    */
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/abit.jpg)", "http&#58;//www.abit-usa.com", "comp"&#41;;i++ 
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/aopen.jpg)", "http&#58;//www.aopen.com.tw", "comp"&#41;;i++   
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/asrock.jpg)", "http&#58;//www.asrock.com/", "comp"&#41;;i++  
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/asus.jpg)", "http&#58;//usa.asus.com/index.htm", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/connect3djpg.jpg)", "http&#58;//www.connect3d-us.com/index.html", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/dfi.gif)", "http&#58;//www.dfi.com.tw", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/diamondlogo.jpg)", "http&#58;//www.diamondmm.com", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/ecs_logo.jpg)", "http&#58;//www.ecs.com.tw", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/eqs.jpg)", "http&#58;//www.eqscomputers.com", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/hislogo.jpg)", "http&#58;//www.hisdigital.com/html/home.php", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/jetway.jpg)", "http&#58;//www.jetway.com.tw", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/MSI_Logo.jpg)", "http&#58;//www.msicomputer.com/index2.asp", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/pcpartner.jpg)", "http&#58;//www.pcpartner.com", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/powercolorlogo.jpg)", "http&#58;//www.powercolor.com/index.htm", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/sapphire.jpg)", "http&#58;//www.sapphiretech.com", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/shuttle.jpg)", "http&#58;//www.shuttle.com", "comp"&#41;;i++
      Article&#91;i&#93; = new Array &#40;"![image](images/aibodm/visiontech.jpg)", "http&#58;//www.visiontek.com", "comp"&#41;;i++
    
    
    ////// SCROLLER CONFIGURATION ///////////////////////////////////////////////////////////////////  
    orientation = "vertical"        // Orientation of scroller &#40;Horizontal or vertical&#41;
    scrollerWidth = "150"             // Width of entire scroller.
    scrollerHeight = "200"             // Height of Scroller.
    borderWidth = 0                   // Width of border. &#40;use 0 for no border&#41;.
    borderColour = "#006600"          // Colour of scroller border. &#40;Use either hexadecimal or text values. e.g. "#FF0000" or "Red"&#41; 
    backColour = "white"              // Colour of scroller background. &#40;Use either hexadecimal or text values. e.g. "#FF0000" or "Red"&#41; 
    staticColour = "#000000"          // Colour of scroller items that are NOT a link. &#40;including scrollerDivider characters&#41;
    stopScroll = 1                    // Pause the scroller on mouseOver. &#40;use 0 for no.&#41;
    textAlignment="center"            // Alignment of each scroller item.  Only really makes a difference on vertical scroller
                                      // &#40;center, left, right, justify&#41;
    
    // Scroller Links
    linkFont = "arial"                // Font of scroller links;
    linkWeight = "normal"             // Weight of scroller links;
    linkColour = "#006600"            // Colour of scroller links
    linkSize = "10"                   // Size of links &#40;in points&#41;
    linkDecoration = "none"           // Decoration of links. &#40;underline, overline, none&#41;
    
    // Scroller Links On MouseOver
    slinkFont = "arial"               // Font of scroller links;
    slinkWeight = "normal"            // Weight of scroller links;
    slinkColour = "#AFAF9D"           // Colour of scroller links
    slinkSize = "10"                  // Size of links &#40;in points&#41;
    slinkDecoration = "underline"     // Decoration of links. &#40;underline, overline, none&#41;
    
    scrollerDivider = "" // Character to place between each scroller item. 
                                      // <img> tags can be used if an image is required. 
                                      // Use "0" for nothing.  For Vertical scrollers, it is best to use "
    "
    /* 
      Because Netscape version 4 does not support this scroller, configure the values below so NS4 users do not see an error. 
      In the scroller's place will be a static title which can be a link if require.  The appearance of the static text &#40;colour, scroller border etc&#41;
      will be exactly the same as for the working version in other browsers.
    */
    ns4Text = "Click Here to view details on our partners.";  // Alternative text to display in Netscape 4.
    ns4URL = "https&#58;//";            // URL of link in NS4. If no URL is required, enter "none"
    ns4Target = "comp";                           // Frame target for link in NS4
    
    
    ////// DO NOT EDIT BELOW THIS LINE  ///////////////////////////////////////////////////////////////////
    
    //Browser Sniffer
    var isIE = &#40;document.getElementById && document.all&#41;?true&#58;false;
    var isNS4 = &#40;document.layers&#41;?true&#58;false;
    var isNS6 = &#40;document.getElementById && !document.all&#41;?true&#58;false;
    var isLoaded=false;
    
    style='<style type="text/css">';
    style+='p&#123;font-family&#58;'+linkFont+'; color&#58;'+staticColour+'; font-size&#58;'+linkSize+'pt; font-weight&#58;'+linkWeight+'; text-align&#58;'+textAlignment+'&#125;';
    style+='a.rcScroller,a.rcScroller&#58;active,a.rcScroller&#58;visited&#123;color&#58;'+linkColour+';text-decoration&#58;'+linkDecoration+'; font-weight&#58;'+linkWeight+'&#125;';
    style+='a.rcScroller&#58;hover&#123;color&#58;'+slinkColour+';text-decoration&#58;'+slinkDecoration+'; font-weight&#58;'+slinkWeight+'&#125;';
    style+='rcScrollerHoverNS&#123;color&#58;red;text-decoration&#58;'+slinkDecoration+'; font-weight&#58;'+slinkWeight+'&#125;';
    style+='<\/style>';
    document.writeln&#40;style&#41;;
    
    // Build the scroller and place it on the page
    function buildScroller&#40;&#41;
    &#123;
      boundry='<div name="boundry" id="boundry" style="position&#58;relative"></div>';
      document.writeln&#40;boundry&#41;;
    &#125;
    
    function loadScroller&#40;&#41;&#123;
      if&#40;isNS4&#41;&#123;
        scroller='<table border="0" cellpadding="0" cellspacing="0" width="'+scrollerWidth+'" bgcolor="'+borderColour+'"><tr><td>'
        scroller+='<table border="0" cellpadding="3" cellspacing="1" width="100%" height="'+scrollerHeight+'" bgcolor="'+backColour+'"><tr><td align="center" nowrap>
    
    ';
        if&#40;ns4URL.toLowerCase&#40;&#41;!="none"&#41;&#123;scroller+='[url="'+ns4URL+'"]'+ns4Text+'';&#125;
        else&#123;scroller+=ns4Text;&#125; 
        scroller+='</p></td></tr></table></td></tr></table>'   
      &#125;else&#123;
        scroller='<table border="0" cellpadding="0" cellspacing="0" style="width&#58;'+scrollerWidth+';height&#58;'+scrollerHeight+';border&#58;'+borderWidth+'px solid '+borderColour+';background-color&#58;'+backColour+'">';
        scroller+='<tr valign="middle"><td><div id="div" style="';
        if&#40;orientation.toLowerCase&#40;&#41;=="vertical"&#41;&#123;scroller+='height&#58;'+scrollerHeight+';';&#125;
        scroller+='width&#58;'+scrollerWidth+'; position&#58;relative; background-color&#58;'+backColour+'; overflow&#58;hidden">';
        scroller+='<div id="div1" style="position&#58;relative; left&#58;0; z-index&#58;1">';
        scroller+='<table border="0" name="table" id="table"';
        if&#40;orientation.toLowerCase&#40;&#41;=="vertical"&#41;&#123;scroller+='style="width&#58;'+scrollerWidth+'"';&#125;
        scroller+='><tr>';
        y=0;
        while &#40;y<4&#41;
        &#123;
          for &#40;x=0; x<&#40;Article.length&#41;; x++&#41;
          &#123;
            if&#40;orientation.toLowerCase&#40;&#41;=="vertical"&#41;&#123;scroller+='<tr>';&#125;
            scroller+='<td ';
            if&#40;orientation.toLowerCase&#40;&#41;=="horizontal"&#41;&#123;scroller+='nowrap';&#125; if&#40;stopScroll==1&#41;&#123;scroller+=' onMouseOver="stopScroller&#40;&#41;;" onMouseOut="setWidth&#40;&#41;"';&#125;
            scroller+='>
    
    ';
            if&#40;Article&#91;x&#93;&#91;1&#93;.toLowerCase&#40;&#41;!="none"&#41;&#123;scroller+='<a class="rcScroller" href="'+Article&#91;x&#93;&#91;1&#93;+'" target="'+Article&#91;x&#93;&#91;2&#93;+'" >'+Article&#91;x&#93;&#91;0&#93;+'<\/a>';
            &#125;else&#123;scroller+=Article&#91;x&#93;&#91;0&#93;;&#125;          
            scroller+='</p><\/td>';
            
            if&#40;orientation.toLowerCase&#40;&#41;=="vertical"&#41;&#123;scroller+='<\/tr>';&#125;
                  
            if&#40;scrollerDivider.toLowerCase&#40;&#41; != "none"&#41;&#123;scroller+='<td nowrap>
    
    '+scrollerDivider+'<\/p><\/td>';&#125;
          &#125;
          y++
        &#125;
        scroller+='<\/tr><\/table><\/div><\/div><\/td><\/tr><\/table>';  
      &#125;
      document.getElementById&#40;"boundry"&#41;.innerHTML=scroller;
      setWidth&#40;&#41;;
    &#125;
    
    
    // Ensure the width of the scroller is divisible by 2. This allows smooth flowing of the scrolled content
    function setWidth&#40;&#41;
    &#123; 
      tableObj=&#40;isIE&#41;?document.all&#40;"table"&#41;&#58;document.getElementById&#40;"table"&#41;; 
      obj=&#40;isIE&#41;?document.all.div1&#58;document.getElementById&#40;"div1"&#41;;   
      objWidth=&#40;orientation.toLowerCase&#40;&#41;=="horizontal"&#41;?getOffset&#40;tableObj,"width"&#41;&#58;getOffset&#40;tableObj,"height"&#41;;
      HalfWidth=Math.floor&#40;objWidth/2&#41;;
      newWidth = &#40;HalfWidth*2&#41;+2;
      obj.style.width=newWidth
      moveLayer&#40;obj, newWidth&#41;;
      
    &#125;
    
    // Move the layer by one pixel to the left
    function moveLayer&#40;obj, width&#41;
    &#123;
      
      maxLeft = &#40;0-&#40;width/2&#41;+2&#41;/2
      if&#40;orientation.toLowerCase&#40;&#41;=="horizontal"&#41;&#123;
        obj.style.left=&#40;parseInt&#40;obj.style.left&#41; <= maxLeft&#41;?0&#58;parseInt&#40;obj.style.left&#41;-1
      &#125;else&#123;
        if&#40;obj.style.top==""&#41;&#123;obj.style.top=0;&#125;
       // alert&#40;obj.style.top&#41;
        if &#40;parseInt&#40;obj.style.top&#41;<&#40;0-&#40;width/2&#41;+6&#41;&#41;&#123;
          obj.style.top = 0
        &#125;else&#123;
          obj.style.top = parseInt&#40;obj.style.top&#41;-1
        &#125;
      &#125;
      timer = setTimeout &#40;"moveLayer&#40;obj, "+width+"&#41;;", 25&#41;; 
    &#125;
    
    // Get width and height of layer
    function getOffset&#40;obj, dim&#41; 
    &#123;
      if&#40;dim=="width"&#41;
      &#123;
        oWidth = obj.offsetWidth
        return oWidth
      &#125;  
      else if&#40;dim=="height"&#41;
      &#123;
        oHeight = obj.offsetHeight
        return oHeight
      &#125;    
    &#125;
    
    function stopScroller&#40;&#41;
    &#123;
      clearTimeout&#40;timer&#41;  
    &#125;
    
    ////// END OF SCRIPT  ///////////////////////////////////////////////////////////////////
    //-->
    
    </script>
    

    Cosa molto strana ...
    Solitamente nei Javascript vi e' uno script di lancio per ogni funzione di tipo <body onLoad="startscroll()"> ma non vedo nessun tipo di script esecutore qui... "forse mi sbaglio"
    Se qualcuno mi puo' aiutare a capire quanto scritto sopra gli sono molto grato...

    Grazie