Closed Bug 327380 Opened 15 years ago Closed 15 years ago

if you have an existing hidden IFrame, you can't send a request using contentDocument

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 100533

People

(Reporter: czou, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

I have a hidden IFrame in my html, when I click a button, it executes a javascript method, which makes the IFrame visible and load a page into the IFrame. This is all working fine with firefox 1.0.7, but it doesn't work with firefox 1.5.0.1. 

Reproducible: Always

Steps to Reproduce:
1. Save the following as a html file
<script src='ff.js' type='text/javascript' language='JavaScript1.2'></script>
<html>
<body>
Click the button below, it will invoke a javascript, which in turn will
retrieve www.yahoo.com into the iframe
<p>
<input type="button" value="Click Me!" onClick="sendCommandToServer()"/>

<iframe id='myiframe' style="display:none;" src='http://www.google.com'></iframe>
</body>
</html>

2. Save the following as ff.js file
function sendCommandToServer() {
    var parameter = "";
    parameter += "<body>";
    var url="http://www.yahoo.com";
    parameter += "<form id='sendform' action='" + url + "' method='GET'>";
    parameter += "<input type='hidden' name='action' value='yahoo'>";
    parameter += "</form>";
    parameter += "<script>document.getElementById( 'sendform' ).submit();</script>";
    parameter += "</body>";

    var iframe = document.getElementById('myiframe');

    iframe.style.display = "";
    iframe.contentDocument.open();
    iframe.contentDocument.write(parameter);
    iframe.contentDocument.close();
}
3. Click the button

Actual Results:  
IFrame shows up, but there is no content

Expected Results:  
IFrame shows up, www.yahoo.com is loaded into the IFrame

I found a workaround for this. Instead of having style="display:none", I can have style="visibility:hidden", then in the javascript, changes it to 'visible'. This will achieve the same effect. But in this way, even though initially the IFrame is hidden, it still takes space in the page, which is not nice.
WFM with Mozilla 1.8a3, reproducible with Mozilla 1.8a4 and SeaMonkey 1.5a/20051108 but it starts working again with SeaMonkey 1.5a/20051109. After querying Bonsai for 'frame' bugs -> maybe fixed by Core bug 315541?
Bug 315541 dealt with :before and :after styles.  There aren't any here.

On the other hand, bug 100533 dealt with form.submit() in display:none iframes, which is pretty directly relevant here.

For future reference, please list the hour in the build id too; it makes working with bonsai much easier.

*** This bug has been marked as a duplicate of 100533 ***
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Reporter: as another workaround, you can do:

  var dummy = document.body.offsetWidth;

in the subframe's JS right before calling submit().  That should fix the problem.
You need to log in before you can comment on or make changes to this bug.