Support » Fixing WordPress » How to output a msg in a day/night

Viewing 1 replies (of 1 total)
  • taghaboy,

    I inserted your script into footer.php, and it worked well as long as the script is after the defined span & div.

    In your example, this appeared to work ok:

    <span id="Bonjour">Bonjour</span>
    <div id="Time"></div>
    .
    . more code
    
    <?php wp_footer(); ?>
    
    <script type='text/javascript'>
    today = new Date();
    document.getElementById('Time').innerHTML = today.getHours();
      if (today.getHours() < 0 || today.getHours() >= 18) {
        document.getElementById('Bonjour').innerHTML = 'Test Bonsoir';
    }
    </script>

    This did not work:

    <script type='text/javascript'>
    today = new Date();
    document.getElementById('Time').innerHTML = today.getHours();
      if (today.getHours() < 0 || today.getHours() >= 18) {
        document.getElementById('Bonjour').innerHTML = 'Test Bonsoir';
    }
    </script>
    
    <span id="Bonjour">Bonjour</span>
    <div id="Time"></div>
    .
    . more code
    
    <?php wp_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘How to output a msg in a day/night’ is closed to new replies.