Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > document.close() on dynamic iframe on firefox does not close the connection.

Reply
Thread Tools

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

 
 
hyejin
Guest
Posts: n/a
 
      08-27-2006
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.

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-27-2006


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/
 
Reply With Quote
 
 
 
 
hyejin
Guest
Posts: n/a
 
      08-28-2006
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/


 
Reply With Quote
 
hyejin
Guest
Posts: n/a
 
      08-28-2006
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/


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      08-28-2006
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/
 
Reply With Quote
 
hyejin
Guest
Posts: n/a
 
      08-29-2006

> 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?

 
Reply With Quote
 
hyejin
Guest
Posts: n/a
 
      08-29-2006
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/


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      08-29-2006
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/
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      08-29-2006


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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a TCP socket? (TCPSocket#close doesn't close it) IƱaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
file.close() does not really close under Windows? Dani Python 3 12-17-2009 02:49 PM
this.Connection.Close(); does not close the Oracle session! Pleasehelp! S_K ASP .Net 6 12-07-2007 02:07 PM
Why does JdbcRowSetImpl.close() close the database connection? Paul van Rossem Java 0 04-07-2005 07:01 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments