Web Analytics Made Easy -
StatCounter Determinining if a page has loaded completely - CodingForum

Announcement

Collapse
No announcement yet.

Determinining if a page has loaded completely

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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?

      Comment


      • #4
        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

        Comment


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

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

          Comment


          • #6
            I do not think this is possible - specific elements .. such as a picture?

            Comment


            • #7
              there is a complete method..

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

              Comment


              • #8
                Never heard of that...

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

                ~Quack

                Comment


                • #9
                  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!

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      More info

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

                      Comment


                      • #12
                        Not according to Alex Vincent's JavaScript Developers Dictionary. Sorry

                        Comment


                        • #13
                          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...

                          Comment


                          • #14
                            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>

                            Comment


                            • #15
                              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/

                              Comment

                              Working...
                              X