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

Discussion in 'Javascript' started by hyejin, Aug 27, 2006.

  1. hyejin

    hyejin Guest

    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.
    hyejin, Aug 27, 2006
    #1
    1. Advertising

  2. Re: document.close() on dynamic iframe on firefox does not closethe connection.

    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/
    Martin Honnen, Aug 27, 2006
    #2
    1. Advertising

  3. hyejin

    hyejin Guest

    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/
    hyejin, Aug 28, 2006
    #3
  4. hyejin

    hyejin Guest

    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/
    hyejin, Aug 28, 2006
    #4
  5. hyejin

    Randy Webb Guest

    Re: document.close() on dynamic iframe on firefox does not closethe connection.

    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/
    Randy Webb, Aug 28, 2006
    #5
  6. hyejin

    hyejin Guest


    > 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?
    hyejin, Aug 29, 2006
    #6
  7. hyejin

    hyejin Guest

    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/
    hyejin, Aug 29, 2006
    #7
  8. hyejin

    Randy Webb Guest

    Re: document.close() on dynamic iframe on firefox does not closethe connection.

    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/
    Randy Webb, Aug 29, 2006
    #8
  9. Re: document.close() on dynamic iframe on firefox does not closethe connection.

    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/
    Martin Honnen, Aug 29, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul van Rossem
    Replies:
    0
    Views:
    590
    Paul van Rossem
    Apr 7, 2005
  2. S_K
    Replies:
    6
    Views:
    642
    Russell
    Dec 7, 2007
  3. Replies:
    0
    Views:
    480
  4. Daedalous
    Replies:
    3
    Views:
    653
    Daedalous
    Jan 16, 2004
  5. sam
    Replies:
    1
    Views:
    171
    Csaba Gabor
    Apr 13, 2006
Loading...

Share This Page