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