Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    417

    Visualizzare div in determinati orari e giorni

    Ciao a tutti

    avrei la necessita che in due o tre fascie orarie venisse fuori un div con scritto aperto o chiuso cercando un po nel forum ho trovato ed adattato degli script fino ad arrivare a questa soluzione se non uso la funziona document.getElementById('centro').style.visibility = 'visible'; gli alert funzionano se invece insrisco quella variabili non va più lo scirpt.

    altra cosa si riesce con java a digli funziona solo dal lunedì al martedì lo script?

    grazie in anticipo

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    centro{
    visibility: hidden;
    width: 200px;
    height: 200px;
    background-color: black;
    }
    </style>
    <script language="javascript" type="text/javascript">
    <!--
    function aperto(){
    var data=new Date();
    if (data.getHours()==21 && data.getMinutes()=02 && data.getSeconds()==0){
    document.getElementById('centro').style.visibility = 'visible';
    alert('aperto!!');
    }
    setTimeout("aperto()",1000);
    }

    //-->
    <!--
    function chiuso(){
    var data=new Date();
    if (data.getHours()==21 && data.getMinutes()==03 && data.getSeconds()==0){
    document.getElementById('centro').style.display = "block";

    alert('chiuso!!');
    }
    setTimeout("chiuso()",1000);
    }

    //-->
    <!--
    function apertop(){
    var data=new Date();
    if (data.getHours()==15 && data.getMinutes()=30 && data.getSeconds()==0){
    document.getElementById('centro').style.visibility = 'visible';
    alert('aperto pomeriggio!!');
    }
    setTimeout("aperto()",1000);
    }

    //-->
    <!--
    function chiusop(){
    var data=new Date();
    if (data.getHours()==18 && data.getMinutes()==30 && data.getSeconds()==0){
    document.getElementById('centro').style.display = "block";

    alert('chiuso pomeriggio!!');
    }
    setTimeout("chiuso()",1000);
    }

    //-->
    </script>
    </head>

    <body onload="aperto();chiuso();apertop();chiusop();">

    <div id=”centro”>
    ciao ti vedo
    </div>
    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Prova.

    Codice PHP:
    <!DOCTYPE html>
    <
    html>
    <
    head>

    <
    style>
    .
    chiuso {
        
    width200px;
        
    height200px;
        
    background-colorred;
    }

    .
    aperto {
        
    width200px;
        
    height200px;
        
    background-colorgreen;
    }

    </
    style>

    <
    script language="javascript" type="text/javascript">
    <!--

    rangeChiuso = new Array("0000-0559","1200-1359","1900-2359");

    function 
    isClosed(haRange) {

        
    sLL aRange.substr(0,4);
        
    sUL aRange.substr(5,4);
        
    aLL parseInt(sLL);
        
    aUL parseInt(sUL);
        
    //alert(aLL + " " + aUL);
        
    if (aLL <= && <= aUL) {
            return 
    true;
        } else {
            return 
    false;
        }
    }

    function 
    pippo(){
        
        var 
    data=new Date();
        var 
    data.getHours() * 100 data.getMinutes();

        
    max rangeChiuso.length 1;
        
    chiuso false;
        for (
    i=0;i<=max;i++) {
            
            if (
    isClosed(h,rangeChiuso[i])) {
                
    chiuso true;
                
    max 10;
            }
        }

        if (
    chiuso) {            
            
    document.getElementById("centro").className "chiuso";
            
    document.getElementById("centro").innerText 'chiuso';
        } else {
            
    document.getElementById('centro').className 'aperto';
            
    document.getElementById('centro').innerText 'aperto';
        }
    }

    //-->
    </script>
    </head>

    <body>

    <div id="centro" class="centro1" >ciao ti vedo</div>


    <script language="javascript" type="text/javascript">
        setInterval("pippo()",1000);
        // pippo();
    </script>

    </body>
    </html> 
    Ridatemi i miei 1000 posts persi !!!!
    Non serve a nulla ottimizzare qualcosa che non funziona.
    Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr

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.