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


(Firefox :: General, defect)

Windows XP
Not set





(Reporter: czou, Unassigned)


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

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 

Reproducible: Always

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

<iframe id='myiframe' style="display:none;" src=''></iframe>

2. Save the following as ff.js file
function sendCommandToServer() {
    var parameter = "";
    parameter += "<body>";
    var url="";
    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'); = "";;
3. Click the button

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

Expected Results:  
IFrame shows up, 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 ***
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.