Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di MM88
    Registrato dal
    Jun 2003
    Messaggi
    567

    Modificare javascript per preloading

    Ciao, sto utilizzando questo codice per il preloading:


    codice:
    <script>
        // Set slideShowSpeed (milliseconds)
        var slideShowSpeed = 5000
    
        // Duration of crossfade (seconds)
        var crossFadeDuration = 3
    
        // Specify the image files
        var Pic = new Array() // don't touch this
        // to add more images, just continue
        // the pattern, adding to the array below
    
        Pic[0] = '1.ipg'
        Pic[1] = '2.jpg'
        Pic[2] = '3.jpg'
        Pic[3] = '4.jpg'
        Pic[4] = '5.jpg'
    
        // =======================================
        // do not edit anything below this line
        // =======================================
    
        var t
        var j = 0
        var p = Pic.length
    
        var preLoad = new Array()
        for (i = 0; i < p; i++){
           preLoad[i] = new Image()
           preLoad[i].src = Pic[i]
        }
    
        function runSlideShow(){
           if (document.all){
              document.images.SlideShow.style.filter="blendTrans(duration=2)"
              document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
              document.images.SlideShow.filters.blendTrans.Apply()      
           }
           document.images.SlideShow.src = preLoad[j].src
           if (document.all){
              document.images.SlideShow.filters.blendTrans.Play()
           }
           j = j + 1
           if (j > (p-1)) j=0
           t = setTimeout('runSlideShow()', slideShowSpeed)
        }
        </script>
    
    <body onload="runSlideShow()">
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td id="VU" height=150 width=150>
    [img]1.jpg[/img]</td>
    </tr>
    </table>


    Utilizzando la funzione readdir, in che modo dovrei modificare questo codice in modo che costruisca in automatico la parte,

    codice:
        Pic[0] = '1.ipg'
        Pic[1] = '2.jpg'
        Pic[2] = '3.jpg'
        Pic[3] = '4.jpg'
        Pic[4] = '5.jpg'


    leggendo i file da una cartella che andrò a specificare?



    grazie

  2. #2
    Utente di HTML.it L'avatar di MM88
    Registrato dal
    Jun 2003
    Messaggi
    567
    Modificando così il javascript e controllando il codice, mi sembra sia tutto corretto:


    codice:
    <script language="JavaScript" type="text/javascript">
    function right(e) {
    if (navigator.appName == 'Netscape' && 
    (e.which == 3 || e.which == 2))
    return false;
    else if (navigator.appName == 'Microsoft Internet Explorer' && 
    (event.button == 2 || event.button == 3)) {
    //alert("Right Click is Disabled.");
    return false;
    }
    return true;
    }
    document.onmousedown=right;
    if (document.layers) window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown=right;
    </script>
    
    
    <script language="JavaScript" type="text/JavaScript"> 
        // Set slideShowSpeed (milliseconds)
        var slideShowSpeed = 5000
    
        // Duration of crossfade (seconds)
        var crossFadeDuration = 3
    
        // Specify the image files
        var Pic = new Array() // don't touch this
        // to add more images, just continue
        // the pattern, adding to the array below
    
    <? 
    $absolute_path = "images";
    $dir = opendir($absolute_path); 
    $f=array(); 
    
    while($file = readdir($dir)) 
       if (($file != "..") and ($file != ".")) 
           $f[]=$file; 
    
    
    unset($file,$dir); 
    sort($f); 
    
    $i = 0;
    
    foreach($f as $file) 
        echo "Pic[$i] = '$file'\n";
    
    $i++;
    ?>
        
        var t
        var j = 0
        var p = Pic.length
    
        var preLoad = new Array()
        for (i = 0; i < p; i++){
           preLoad[i] = new Image()
           preLoad[i].src = Pic[i]
        }
    
        function runSlideShow(){
           if (document.all){
              document.images.SlideShow.style.filter="blendTrans(duration=2)"
              document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
              document.images.SlideShow.filters.blendTrans.Apply()      
           }
           document.images.SlideShow.src = preLoad[j].src
           if (document.all){
              document.images.SlideShow.filters.blendTrans.Play()
           }
           j = j + 1
           if (j > (p-1)) j=0
           t = setTimeout('runSlideShow()', slideShowSpeed)
        }
        </script>


    Ma osservando la barra di stato non vedo un caricamento di un maggior numero di elementi.

    Le foto in quella cartella vengono caricate realmente anche se non utilizzo la funzione slideshow?

    Come posso verificare la cosa?




    grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.