Results 1 to 3 of 3

Thread: Displaying time, and refreshing

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Displaying time, and refreshing

    My friend wants the time on his page... this is a really easy script... I just don't know the syntax.

    Here's what he had originally:

    HTML Code:
    <style type="text/css">
    span.bigtext {
    font-size: 150%;
    }
    </style>
    ...
    </head><body>
    ...
    <div>
    <SCRIPT>
    document.write("<span class=\"bigtext\">"+Date()+".</span>");
    </SCRIPT>
    </div>
    that works just fine... shows the time, and date and such.

    However... two things:

    1. He doesn't want military time... is this some attribute of the function?

    2. He wants it to refresh...
    I tried messing with making it a recursive function and using "delay 1000", but couldn't get the syntax right... what I know of JS is just what I've seen in passing.


    Should be easy for those who know

    thanks.

    Btw, feel free to change it however you want... the script above is just a starting point. And, yeah, he wants to be able to control the size of the font in css.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Head:
    Code:
    <style type="text/css">
    #time {
      font-size: 150%;
    }
    </style>
    
    <script type="text/javascript">
    function updateTime() {
      var d = new Date();
      document.getElementById("time").innerHTML = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
    }
    window.onload = function() { updateTime(); window.setInterval(updateTime, 1000); };
    </script>
    Body:
    Code:
    <span id="time"></span>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    thanks

    already passed it along to my friend in the web design class.

    he'll be happy.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •