By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>
<scriptcreateDynamicIfram() </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.

Aug 27 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 27 '06 #2

P: n/a
Thank you for the advice. But , if the code in document.write is heavy,
doesn't document.close() cut the stream?
Martin Honnen wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 28 '06 #3

P: n/a
Thank you for the advice. But , if the code in document.write is heavy,
doesn't document.close() cut the stream?
Martin Honnen wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 28 '06 #4

P: n/a
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 28 '06 #5

P: n/a
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?

Aug 29 '06 #6

P: n/a
Randy Webb wrote:
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 29 '06 #7

P: n/a
hyejin said the following on 8/28/2006 9:46 PM:
>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.
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 29 '06 #8

P: n/a


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 29 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.