document.close() on dynamic iframe on firefox does not close the connection.

H

hyejin

I have a problem with dynamic iframe and document.close() on Firefox.
Below two files create a dynamic iframe by JavaScript. These two
samples do not have any problems on IE. But, on Firefox, the icon on
the top corner keeps running with "loading" message on the bottom
status bar even though the browser completed everything in the iFrame.

The line that causes the problem is "document.close()" in the included
JS file. If this line is commented out, the browser does not showing
"loading" message. However, I am in the situation that I cannot control
what it will be in this ifrm_script.js.

Is there any way that I can close the iframe document in the main
script? As you see below, "document.close()" on the onload event on the
main script does not work.


- HTML

<HTML>
<head>test</head>

<body>
<script> createDynamicIfram() </script>

<script>
function createDynamicIfram()
{
var str = '<html><head><title>Advertisement</title></head>'+
'<body id="ifrmBody" leftmargin="0" topmargin="0">' +
'<scr' + 'ipt type="text/javascript" src="ifrm_script.js" ' +
'onload="document.close();" >' +
'</scr' + 'ipt></body></html>';

document.write('<iframe id="dynIFrm" src="about:blank" width="100"
height="100" frameborder="2" scrolling="no"></iframe>');
window.frames["dynIFrm"].document.write(str);
}
</script>
</body>
</HTML>


- ifrm_script.js

document.write('<a href="http://localhost/Click.htm"><img
src="http://localhost/myImg.gif" width="100" height="100" border="0"
/></a>');
document.close(); /// <---- connection never close by this line.
 
M

Martin Honnen

hyejin wrote:

document.write('<iframe id="dynIFrm" src="about:blank" width="100"
height="100" frameborder="2" scrolling="no"></iframe>');
window.frames["dynIFrm"].document.write(str);

Simply call document.close() here on the frame document after the
document.write call.
 
H

hyejin

Thank you for the advice. But , if the code in document.write is heavy,
doesn't document.close() cut the stream?


Martin said:
hyejin wrote:

document.write('<iframe id="dynIFrm" src="about:blank" width="100"
height="100" frameborder="2" scrolling="no"></iframe>');
window.frames["dynIFrm"].document.write(str);

Simply call document.close() here on the frame document after the
document.write call.
 
H

hyejin

Thank you for the advice. But , if the code in document.write is heavy,
doesn't document.close() cut the stream?


Martin said:
hyejin wrote:

document.write('<iframe id="dynIFrm" src="about:blank" width="100"
height="100" frameborder="2" scrolling="no"></iframe>');
window.frames["dynIFrm"].document.write(str);

Simply call document.close() here on the frame document after the
document.write call.
 
R

Randy Webb

hyejin said the following on 8/28/2006 2:34 PM:

More advice:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Thank you for the advice. But , if the code in document.write is heavy,
doesn't document.close() cut the stream?

Did you test it?

It doesn't.
 
H

hyejin

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

That wasn't quite useful, but thanks anyway.

When I changed ifrm_script.js like below instead of writing a simple
image code, the connection was hung no matter where I put
document.close().

for(var i=0; i<100; i++)
{
setInterval( 'document.write(i + "....<br>")',100);
}
document.close();

Is there anyone who knows how to force closing the iframe document no
matter what it is inside on firefox?
 
H

hyejin

Randy said:
hyejin said the following on 8/28/2006 2:34 PM:

More advice:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?


Did you test it?

It doesn't.
 
R

Randy Webb

hyejin said the following on 8/28/2006 9:46 PM:
That wasn't quite useful, but thanks anyway.

It got you to not top-post so it was quite useful.
When I changed ifrm_script.js like below instead of writing a simple
image code, the connection was hung no matter where I put
document.close().

for(var i=0; i<100; i++)
{
setInterval( 'document.write(i + "....<br>")',100);
}
document.close();

Is there anyone who knows how to force closing the iframe document no
matter what it is inside on firefox?

Re-read Martin's reply. He didn't say to put the document.close() call
in the .js file, but to put it in the HTML file that creates the IFrame.
 
M

Martin Honnen

hyejin wrote:

When I changed ifrm_script.js like below instead of writing a simple
image code, the connection was hung no matter where I put
document.close().

for(var i=0; i<100; i++)
{
setInterval( 'document.write(i + "....<br>")',100);
}
document.close();

Is there anyone who knows how to force closing the iframe document no
matter what it is inside on firefox?

Well you have to call document.close() after the last document.write()
call. If you use setInterval and document.write then you obviously do
not want to close the document at all as long as setInterval calls
document.write again and again.
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top