Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Write local time to page

    Hi,

    How can I modify this script so that the local time shows on my home page at load, with no button- or link-clicking necessary? In other words, I want my local time to write automatically on my home page at load, but I don't want it in a separate alert box/window.

    I tried changing "alert" in the function to "document.write" and calling the function in the body, and it does write, but ON A TOTALLY SEPARATE PAGE from my home page. If I keep the "alert" as-is, and call the function in the body, the time writes in an alert window. Again, not what I want. Any ideas?

    <head>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
    <!-- Begin
    function showlocaltime() {
    var today = new Date();
    var difftime = (today.getTimezoneOffset()+540) *60000;
    today.setTime(today.getTime()+difftime);
    alert(today.toLocaleString());
    }
    // End -->
    </script>

    </head>

    <body>

    <div align="center">
    Click <a href="javascript:showlocaltime()">[here]</a> to find the current local time.
    </div>

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    <head>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
    <!-- Begin
    function showlocaltime() {
    var today = new Date();
    var difftime = (today.getTimezoneOffset()+540) *60000;
    today.setTime(today.getTime()+difftime);

    }
    // End -->
    </script>

    </head>

    <body>

    <script>
    document.write(today.toLocaleString());
    </script>

    </body>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Received error

    Thanks for your help.

    When I tried this, I got an error saying "today" was undefined. Any other ideas?

  • #4
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    whoops, sorry, didn't take a close enough look at the code.

    <head>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
    <!-- Begin
    function showlocaltime() {
    var today = new Date();
    var difftime = (today.getTimezoneOffset()+540) *60000;
    today.setTime(today.getTime()+difftime);
    return today.toLocaleString();
    }
    // End -->
    </script>

    </head>

    <body>

    <script>
    document.write(showlocaltime());
    </script>

    </body>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #5
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up To joh6nn

    Hey,

    All is well. Thanks much. I've been beating my head against the wall for weeks trying to figure this out.

    Thanks for your time, energy and willingness to share your knowledge.

  • #6
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    not a problem.

    and good luck for today's game.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

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