470,619 Members | 2,065 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

how can I tell when a page is done reloading?

I want to reload a url in a browser window so I do something like this:
open(window.location.href= "www.yahoo.com");

ok, so now I want to do something when that page is done loading
completely. how do I do this?
What I have tried is this:
a=open(window.location.href= "www.yahoo.com");
a.onload=b();

function b(){
alert("Done!!");
}

but none of this works. I am only concerned with IE.
Any advice on how I can get this to work?
My goal, if not clear from above, is to load some arbitrary page in a
window and then do <something else>, function b(), only when that page
is completely done loading.

Aug 5 '05 #1
16 2756

In IE, use the onreadystatechange event handler in the Body:

<body onreadystatechange="if(this.readyState=='loaded'){ ....}"> however,
onload= works the same way.
Danny
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Aug 5 '05 #2
No, you didn't understand. I have no control over the content of the
child window. If I did I would have used onload or whatever you
suggested already.
How do I tell when a child window is done loading? WHEN I HAVE NO
CONTROL OVER THE CONTENT OF THE CHILD WINDOW.

Aug 5 '05 #3
Ivo
"jaialaitech nology" wrote
ok, so now I want to do something when that page is done loading
completely. how do I do this?
What I have tried is this:
a=open(window.location.href= "www.yahoo.com");
Two mistakes: the window.open() method takes three parameters, all optional,
all strings, but you have a script statement there. The first parameter is
the url to open, either relative to the current page, or absolute, in which
case the protocol, usually http:,is required; the second and third specify
the name and features such as bars and sizes.
What you pass as the parameter here, is the returnvalue of the Javascript
statement window.location.href=etc. This happens to be the string that
contains the url, but the protocol is missing so it is interpreted
relatively.
What you are looking for is something like this:
window.open( "http://www.yahoo.com" );
a.onload=b();


One: When assigning a function to an event handler, you don't necessarily
want to execute that function. Drop the brackets () and you 're fine.
However: this will never work cross-domain. Browser built-in security
measures prevent JavaScript from accessing pages that are not from the same
domain. Only when you open a window with a page from your own site, can you
attach onload event handlers and other stuff. For more on this, try
< http://www.google.com/search?q=same+origin+policy >

hth
ivo
http://www.ariel.shakespearians.com/



Aug 5 '05 #4
alu

"jaialai technology" <ja****************@gmail.com> wrote
a=open(window.location.href= "www.yahoo.com");

See the FAQ http://jibbering.com/faq/#FAQ4_42
& report back if you still have problems.
-alu
Aug 5 '05 #5
ok, I am reporting back to say that that faq has nothing to do with
checking the status of a child window. Thanks for not even bothering to
read my question.

Aug 5 '05 #6
after a few hours of misery I got this
var windowReference =
open(external.menuArguments.location.href=doc.URL) ;

while(windowReference.document.readyState!="comple te"){}
<do-something>

Which simply creates the child window and then loops until it is done
loading. This works for what I want.
Not sure why this took so long. seems like I had to run through quite a
few permutatins of window rewferences and different attempts at
ascertaining some sort of status of the child window.

Aug 5 '05 #7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jaialai technology wrote:
[...]
Which simply creates the child window and then loops until it is done
loading. This works for what I want.
You realise that if you busy wait like this for too long, there's a fair
chance that the client's web browser will decide that the script's crashed
and nuke it? This may be triggered by, for example, a slow 'net connection.
Not sure why this took so long. seems like I had to run through quite a
few permutatins of window rewferences and different attempts at
ascertaining some sort of status of the child window.


You're probably running afoul of the security rules --- there isn't much you
can do with a frame or window containing a page belonging to a different
domain.

BTW: you might get more people willing to help if you didn't shout so much.
Some of your other messages are definitely a bit on the rude side.

- --
+- David Given --McQ-+ "The sky was the perfect untroubled blue of a
| dg@cowlark.com | television screen, tuned to a dead channel." ---
| (dg@tao-group.com) | Neil Gaiman, _Neverwhere_
+- www.cowlark.com --+

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC8yvqf9E0noFvlzgRAqerAKDM/jdheKD6QB0D/eQYagbvTWOHvwCfTgmU
VcXTplyl6uuYuDZGY9bjy9M=
=CJHJ
-----END PGP SIGNATURE-----
Aug 5 '05 #8
This newsgroups is all but dead. I wouldn't shout if there was anybody
here with a clue. Mostly just a bunch of stupid assed curries begging
for someone to do their work for them.
Anyway, I ended up solving my own problem so posting here was just a
waste of time.

Aug 5 '05 #9
Ivo
"jaialai technology" wrote
This newsgroups is all but dead. I wouldn't shout if there was anybody
here with a clue.


Well who am I to expect or even hope for the tiniest bit of thanks for
trying to be helpful, warning for potential oversights and other forms of
narrowmindedness, and various similarly carefully chosen words. I have seen
quite a few newsgroups, and the discussions on this particular one happen to
be among the friendliest and most intelligent around imho (which perhaps
sais more about the other groups, but never mind that). Only generally
speaking, of course.
Here 's to a happy life, jaialai!
hth
ivo
Aug 5 '05 #10
jaialai technology wrote:
ok, I am reporting back to say that that faq has nothing to do with
checking the status of a child window. Thanks for not even bothering to
read my question.

Stop being rude and people MIGHT read your question, being rude does not
help somebody if they misunderstood the question, in which case -
normally - it is the fault of the OP..

--
Hope This Helped and MTFBWY...
Kieren aka JediFans - <URL:http://jedifans.com/>
The Force Is With Me, SuSE Linux Professional 9.3, Mozilla Firefox
1.0.6, Mozilla Thunderbird 1.5 Alpha 2 and Revenge Of The Sith!
Aug 5 '05 #11
Danny said the following on 8/3/2005 12:33 AM:

In IE, use the onreadystatechange event handler in the Body:

<body onreadystatechange="if(this.readyState=='loaded'){ ....}">
however, onload= works the same way.


You never cease to amaze me with your incompetence. The above only works
if the page is from the same domain. Since the OP wanted to load an
"arbitrary page" then it is feasible that the page is not from the same
domain which means it is *impossible* to do the above.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 5 '05 #12
David Given said the following on 8/5/2005 5:05 AM:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Please see the group FAQ with regards to PGP Signed Messages.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 5 '05 #13
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Randy Webb wrote:
[...]
Please see the group FAQ with regards to PGP Signed Messages.


I had a look in 'Quick Answers' and 'META' but didn't see anything relevant
- --- can you provide any more detailed pointers?

- --
+- David Given --McQ-+ "Information wants to be free, but my mail client
| dg@cowlark.com | does not want to be chock-full of herbal pot
| (dg@tao-group.com) | alternative spam." --- Sant Lupus on Slashdot
+- www.cowlark.com --+

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC90jlf9E0noFvlzgRAg3OAKDWwz1HcuWMUhH9gIpT1L TW3bsFeQCgocVm
UoWdCM49xinbpq2qqSgVBJI=
=fdeP
-----END PGP SIGNATURE-----
Aug 8 '05 #14
David Given said the following on 8/8/2005 7:55 AM:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Randy Webb wrote:
[...]
Please see the group FAQ with regards to PGP Signed Messages.

I had a look in 'Quick Answers' and 'META' but didn't see anything relevant
- --- can you provide any more detailed pointers?


PGP Signed is not plain text, and that is covered in the FAQ,
specifically section 2.3 and is also discussed here:

<URL: http://www.jibbering.com/faq/faq_not...s1.html#ps1Txt >

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 8 '05 #15
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Randy Webb wrote:
[...]
PGP Signed is not plain text, and that is covered in the FAQ,
specifically section 2.3 and is also discussed here:


It is plain text, with annotations. I'm sorry, but I have no intention of
not signing my messages. Feel free to killfile me if you like, but I feel
that preventing spoofing of my messages outweighs any (very tiny) drawbacks
to signing my messages --- Usenet is not a nice place.

- --
+- David Given --McQ-+
| dg@cowlark.com | "While I write this letter, I have a pistol in one
| (dg@tao-group.com) | hand and a sword in the other." --- Sir Boyle Roche
+- www.cowlark.com --+

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC+Oi8f9E0noFvlzgRAqm0AKCQoPr0yneGWqLDdImLLC Yl+v5oIgCaAz8e
nZQ46eR0LpbTll9A0IFa9Bg=
=PBnq
-----END PGP SIGNATURE-----
Aug 9 '05 #16
JRS: In article <TJ********************@comcast.com>, dated Mon, 8 Aug
2005 16:59:27, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
PGP Signed is not plain text, and that is covered in the FAQ,
specifically section 2.3 and is also discussed here:

<URL: http://www.jibbering.com/faq/faq_not...s1.html#ps1Txt >


Provided that the material which is composed for signature is plain
text, I see no need for objection; the signature itself is reasonably
small. A good newsreader will not show the PGP stuff as sent, but just
give an indication.

News:uk.* practice explicitly permits their use.

Since the FAQ notes do not appear in News, they cannot have authority in
respect of News.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Plaintext, quoting : see <URL:http://www.usenet.org.uk/ukpost.html>
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
Aug 9 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alex Hunter | last post: by
3 posts views Thread by micchy | last post: by
2 posts views Thread by Jack David | last post: by
3 posts views Thread by Richard | last post: by
10 posts views Thread by Martien van Wanrooij | last post: by
4 posts views Thread by BigZero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.