Waiting for a site to finish loading

Discussion in 'Javascript' started by Brett, May 28, 2005.

  1. Brett

    Brett Guest

    I have just picked up javascript so that I can write some scripts for
    Greasemonkey. For those not familiar with grease monkey it is a program
    that allows you to change websites before you view them. Very cool
    program.

    Anyway I want to write a script that waits until the entire page is
    loaded to run. I am working with very large pages that take a while to
    load.

    Does anyone know how to do this? or any good websites for looking up
    this sort of information?

    Brett
    Brett, May 28, 2005
    #1
    1. Advertising

  2. Brett

    mscir Guest

    mscir, May 28, 2005
    #2
    1. Advertising

  3. Brett

    Brett Guest

    Hmm yeah I found something that said OnLoad was the event I was looking
    for but this does not really work. At the moment I am trying to write a
    script file that makes a message popup displaying the title of the
    page. If this code is run before the title is loaded then it obviously
    is not going to work properly.

    so far I have this
    <SCRIPT>
    window.onload( alert(document.title) );
    </SCRIPT>

    it pops up with a blank message. But when i use this code instead. It
    will work provided I have it at the bottom of the page.

    <SCRIPT>
    alert(document.title);
    </SCRIPT>

    So it seems that the onload is either not doing what it is supposed to
    do or I am not using it properly. Any Ideas?

    Brett

    Thank you for the web pages btw they will help me alot.

    mscir wrote:
    > Brett wrote:
    > > ...
    > > Anyway I want to write a script that waits until the entire page is
    > > loaded to run. I am working with very large pages that take a while to
    > > load.
    > >
    > > Does anyone know how to do this? or any good websites for looking up
    > > this sort of information?
    > >
    > > Brett

    >
    > http://scriptasylum.com/tutorials/pageevents.html
    >
    > http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onload.html
    >
    > Mike
    Brett, May 28, 2005
    #3
  4. Brett

    Randy Webb Guest

    Brett wrote:
    > Hmm yeah I found something that said OnLoad was the event I was looking
    > for but this does not really work.


    It does if you use it properly.

    > At the moment I am trying to write a script file that makes a message
    > popup displaying the title of the page. If this code is run before the
    > title is loaded then it obviously is not going to work properly.


    True.

    > so far I have this
    > <SCRIPT>
    > window.onload( alert(document.title) );
    > </SCRIPT>


    window.onload=someFunction;
    function someFunction(){
    alert(document.title);
    }

    Had you bothered to read the group FAQ you wouldn't be asking this.

    > it pops up with a blank message. But when i use this code instead. It
    > will work provided I have it at the bottom of the page.
    >
    > <SCRIPT>
    > alert(document.title);
    > </SCRIPT>


    It will work anywhere *after* the title tag is presented.

    > So it seems that the onload is either not doing what it is supposed to
    > do or I am not using it properly. Any Ideas?


    1) You are not using it properly.
    2) Read the group FAQ.
    3) Search the c.l.j archives.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Randy Webb, May 28, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    14,091
    Matt Humphrey
    Apr 22, 2005
  2. Behrang Dadsetan

    Waiting for processes to finish under Solaris

    Behrang Dadsetan, Jul 15, 2003, in forum: Python
    Replies:
    1
    Views:
    519
    Behrang Dadsetan
    Jul 15, 2003
  3. Martin DeMello
    Replies:
    1
    Views:
    177
    Farrel Lifson
    Nov 13, 2006
  4. matej
    Replies:
    1
    Views:
    102
    Bjoern Hoehrmann
    Jun 25, 2008
  5. Roedy Green
    Replies:
    31
    Views:
    570
    Robert Klemme
    Jan 26, 2013
Loading...

Share This Page