469,348 Members | 1,252 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

capturing page load

Hi all. I know this is more of a DOM question, but here it goes:

Browser == Firefox

suppose I have two frames. One has many links and is opening pages in
the other one. I would like to check if the page is finished loading.

This is the example of the "links" frame.
----

<html>
<head>
<title>Frame1</title>
<script type="text/javascript">
<!--
function loadDocument() {
content = window.open( "frame2.html", "Content" );
content.addEventListener( "load", sayDone, false );
}

function sayDone() {
alert( "done" );
}

//-->
</script>
</head>
<body>
<input type="button" value="Open frame 2" onclick="loadDocument()">
</body>
</html>

----

The problem I'm having is, that this only works the first time. If I
click on the button again, the load event is not captured. I didn't
find anything useful when searching the web. Can anybody here help?

Thanks in advance, Miha Vitorovic

Mar 29 '07 #1
4 1445
<mi************@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
Hi all. I know this is more of a DOM question, but here it goes:

Browser == Firefox

suppose I have two frames. One has many links and is opening pages in
the other one. I would like to check if the page is finished loading.

This is the example of the "links" frame.
----

<html>
<head>
<title>Frame1</title>
<script type="text/javascript">
<!--
function loadDocument() {
content = window.open( "frame2.html", "Content" );
content.addEventListener( "load", sayDone, false );
}

function sayDone() {
alert( "done" );
}

//-->
</script>
</head>
<body>
<input type="button" value="Open frame 2" onclick="loadDocument()">
</body>
</html>

----

The problem I'm having is, that this only works the first time. If I
click on the button again, the load event is not captured. I didn't
find anything useful when searching the web. Can anybody here help?
I did not test this, it is merely conjecture. Did you try closing your Window instance?
Perhaps in the sayDone() function you can test if it is open, then close it:

if (content.open) { content.close(); }

Remember, that even after closing your Window instance, the Window object remains. It is
by testing further for the name property, that you see it is null (after closing your
instance).

-Lost
Mar 29 '07 #2
On Mar 29, 2:08 pm, "-Lost" <missed-s...@comcast.netwrote:
<miha.vitoro...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googlegr oups.com...
Hi all. I know this is more of a DOM question, but here it goes:
Browser == Firefox
suppose I have two frames. One has many links and is opening pages in
the other one. I would like to check if the page is finished loading.
This is the example of the "links" frame.
----
<html>
<head>
<title>Frame1</title>
<script type="text/javascript">
<!--
function loadDocument() {
content = window.open( "frame2.html", "Content" );
content.addEventListener( "load", sayDone, false );
}
function sayDone() {
alert( "done" );
}
//-->
</script>
</head>
<body>
<input type="button" value="Open frame 2" onclick="loadDocument()">
</body>
</html>
----
The problem I'm having is, that this only works the first time. If I
click on the button again, the load event is not captured. I didn't
find anything useful when searching the web. Can anybody here help?

I did not test this, it is merely conjecture. Did you try closing your Window instance?
Perhaps in the sayDone() function you can test if it is open, then close it:

if (content.open) { content.close(); }

Remember, that even after closing your Window instance, the Window object remains. It is
by testing further for the name property, that you see it is null (after closing your
instance).

-Lost
Tnx for the suggestion - no luck.

Br, Miha Vitorovic

Mar 29 '07 #3
<mi************@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
On Mar 29, 2:08 pm, "-Lost" <missed-s...@comcast.netwrote:
><miha.vitoro...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googleg roups.com...
Hi all. I know this is more of a DOM question, but here it goes:
Browser == Firefox
suppose I have two frames. One has many links and is opening pages in
the other one. I would like to check if the page is finished loading.
This is the example of the "links" frame.
----
<html>
<head>
<title>Frame1</title>
<script type="text/javascript">
<!--
function loadDocument() {
content = window.open( "frame2.html", "Content" );
content.addEventListener( "load", sayDone, false );
}
function sayDone() {
alert( "done" );
}
//-->
</script>
</head>
<body>
<input type="button" value="Open frame 2" onclick="loadDocument()">
</body>
</html>
----
The problem I'm having is, that this only works the first time. If I
click on the button again, the load event is not captured. I didn't
find anything useful when searching the web. Can anybody here help?

I did not test this, it is merely conjecture. Did you try closing your Window
instance?
Perhaps in the sayDone() function you can test if it is open, then close it:

if (content.open) { content.close(); }

Remember, that even after closing your Window instance, the Window object remains. It
is
by testing further for the name property, that you see it is null (after closing your
instance).

Tnx for the suggestion - no luck.
Do you have a page one can take a look at? I could not imagine that you need to remove
the event listener upon closing your Window instance, but, I could be wrong.

-Lost
Mar 29 '07 #4
On Mar 29, 2:51 pm, "-Lost" <missed-s...@comcast.netwrote:
>
Do you have a page one can take a look at? I could not imagine that you need to remove
the event listener upon closing your Window instance, but, I could be wrong.

-Lost
Sorry, can't do. But I can e-mail you the three HTML files. I's some
13k.

Br, Mike

Mar 29 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

33 posts views Thread by Joerg Schuster | last post: by
4 posts views Thread by Steve Wolfie | last post: by
10 posts views Thread by Andrew | last post: by
1 post views Thread by louise raisbeck | last post: by
2 posts views Thread by Ken Cox - Microsoft MVP | last post: by
6 posts views Thread by Ed Leafe | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.