Waiting for a site to finish loading

B

Brett

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
 
B

Brett

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.
 
R

Randy Webb

Brett said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top