capturing page load

M

miha.vitorovic

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
 
L

-Lost

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
 
M

miha.vitorovic

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
 
L

-Lost

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
 
M

miha.vitorovic

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
 

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
474,266
Messages
2,571,081
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top