473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
8 5343


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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
8
by: '69 Camaro | last post by:
Perhaps I'm Googling for the wrong terms. Does anyone have links to examples of the syntax necessary to read the HTML on another Web page when that HTML is produced from JavaScript using the...
3
by: Asterbing | last post by:
I want to know the length in pixels of a document embedded in a iframe. The way I go seems to work under IE but not under Firefox (about other browsers I'll see later). Here is my page for...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
7
by: Peter | last post by:
I have the following code which is executed from a modal web page - it works fine on most, but on some computers the Word loads into memory but never displays. This occurs with IE6 and IE7, but...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
1
by: raviviswanathan.81 | last post by:
Hello, So we have a webmaster who sets document.domain to some domain. After that, we try to create and inject text inside an iframe by getting the iframeID.contentDocument (or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.