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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Determinining if a page has loaded completely

    Hello all,

    Is there a way to determine if a page has loaded completely?

    Also is there a way to determine if items on a page have also completely loaded?

    Thanks......

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    344
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah...

    what do you need?

    if you use a Javascript, launch it when the page is finished loading...

    Code:
    <html>
    <head>
    <title>test</title>
    <script language="JavaScript">
    <!--
    function sendMessage()
    {
    alert('The page has loaded completely!');
    }
    //-->
    </script>
    </head>
    <body onLoad="sendMessage();">
    </body>
    </html>
    That'll do it.

    ~Quack

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Finding if the page has loaded completely

    I assumed that the onload is the 1st event that occurs; I want to make sure that the page has rendered completely...can this be captured?

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    344
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the onLoad event has fired, the page has completed loading...

    what more do you need?

    Please explain in details what you're trying to accomplish

    ~Quack

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onload occurs after the browser or frames finish loading...doh!

    I want to know if specific elements are loaded....

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    344
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not think this is possible - specific elements .. such as a picture?

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    there is a complete method..

    Does the complete method work for all objects?
    eg: object.complete

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Posts
    344
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never heard of that...

    sorry Krazy, you gotta give me credit though, I did answer your first question...

    ~Quack

  • #9
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Always Thankful

    Yup you are correct!

    You did answer the 1st one!! Thanks...sorry for not explaining my questions as refined as possible...if there is such a method to determine if specific elements have loaded I would like to know...

    Thanks again QuackHead!

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    I think what you are referring to is the readyState property. In IE4+ you should be able to refernece the readySate property like so:

    var x= document.readyState

    which should return 1 of 5 different values:

    unitialized
    loading
    loaded
    interactive
    complete

    so to see if a element is in fact completely loaded you could use:

    var pic=document.images.picname.complete

    which will return true or false depending on the current readySate of that image.

  • #11
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    More info ;)

    Thanks for the info JohnKrutsch!
    Is there an NS equivalent for the readyState?

  • #12
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    Not according to Alex Vincent's JavaScript Developers Dictionary. Sorry

  • #13
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Ok thanks!

    Well, I was thinking if you were to need this event for dynamically creating objects; I suppose that if this method is only for images...

  • #14
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    Tis should work although I download the picture so fast I can't see if it works.

    <html>
    <head>
    <title> </title>
    </head>
    <body>
    <div id="stats"> </div>
    <img name="pic" src="http://home.centurytel.net/jcjoel2002/shed.jpg" width="640" height="480" />
    <script type="text/javascript">
    abc=setInterval("redy()",100);
    function redy(){
    var x= document.images.pic.readyState;
    stats.innerHTML==x;
    if(x=="complete") clearInterval(abc);
    }
    </script>
    </body>
    </html>

  • #15
    New Coder
    Join Date
    Jun 2002
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My cent in.
    As far as images are concerned, they are respondent to onLoad <img src.... onLoad="">
    if you know how many images in a page are or how many are chached for rollovers (I bet this might be one of the underlying problems), you can instruct each image to run a function upon being loaded:
    var finish=0;
    function addF(){++finish}

    then each image <img ... onLoad="addF()">

    and for prechached you may try:

    var anImm=new Image(100,100)
    anImm.src="dunno.jpg"
    anImm.onload=addF;

    To know if a page has loaded all its graphical elements then, you recursively check with a timeout until
    finish= your amount of images

    maybe it is an adjunctive hint for your problem
    ciao
    Alberto http://www.unitedscripters.com/


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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