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 8 of 8
  1. #1
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page Loading Time

    I downloaded a script - http://www.a1javascripts.com/time_re...adingtime.html

    I've also put it below -

    Code:
    <script Language="JavaScript">
    var from_time = new Date();
    from_time = from_time.getTime();
    function  show_loading_time()
    {
    var to_time = new Date();
    to_time = to_time.getTime();
    var secs = (to_time - from_time) /1000;
    }
    </script>
    I would like to write the text in part of the page but I can't do it...

    I tried - <script>document.write(secs)</script> but it says secs is undefined.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try putting an onload event calling your function, also put document.write(secs) in your function.
    <body onload="show_loading_time();">

  • #3
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've done the onload etc, but I want the time to be written in a specific place.

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    I guess i'm confused, if you have it in a function like you do, you'll have to call the function somehow. Maybe you can explain in more detail.

  • #5
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, the function goes in the head, when the onLoad event is triggered, the function is run calculating the page load time. I wish to display the output of that (secs) somewhere in the text in my page.

  • #6
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    I see, well then your not going to want to use document.write(), you're gonna want to use a div, or something of that matter, and write the seconds in there or you can do it like the example page you posted up where they have it in a text box.

  • #7
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm, I'd rather not use a text box as I want it in the actual text.... there must be a way? :S I'll keep trying!

  • #8
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    .....
    Quote Originally Posted by Brandoe85
    I see, well then your not going to want to use document.write(), you're gonna want to use a div, or something of that matter


  •  

    Posting Permissions

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