Connecting Tech Pros Worldwide Forums | Help | Site Map

Iframe submit issue in Firefox

CAG CAG is offline
Newbie
 
Join Date: Oct 2006
Posts: 4
#1: Jul 19 '07
Hello,

I have following scenario in my web application.
I want to load different web forms in single iframe. Iframe in contained in an ASP page. ASP page has “Submit” button, which submits iframe form, & then load new form in same frame.

This is more like slide show of child forms. ASP button also has “Back” button which loads previously submitted form in same iframe. On click of “submit” button, it resubmits child form.

This works fine in IE 6. But in firefox “re-submission” of form does not take place. So that in firefox, child form gets submitted only once.


Sample code

Expand|Select|Wrap|Line Numbers
  1. function setURL(form_url)
  2. {
  3. var iframe = “<iframe id= iframe name= “ + form_label + “ src= ” + form_url;
  4. document.getElementById(“div_name”).innerHTML = iframe;
  5. }
  6.  
  7. function submitForm()
  8. {
  9.     var frameObj = window.frames.form_label;
  10.     if(frameObj.document.childForm)
  11.     {
  12.         frameObj.document.childForm.submit();
  13.             setURL(nextForm_url);
  14.         }
  15. }

above if condition fails in firefox when same child form(i.e with form_label value) is reloaded in iframe. Same code works fine in IE.

Thanks in advanced.

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#2: Jul 19 '07

re: Iframe submit issue in Firefox


hi ...

you posted into the articles-section rather then in the forum ... i moved it across for you ... so that the experts may find and answer it ...

kind regards
Newbie
 
Join Date: Oct 2007
Posts: 1
#3: Oct 8 '07

re: Iframe submit issue in Firefox


I have a very similar problem, i think this is an Firefox bug. I have posted it an i am waiting for an answer...

We have the next situation:
- page with an iframe.
- the iframe contents a function called f().

We want to load the iframe and execute a function inside iframe from outside iframe.


We follow the next steps:

Step 1 - Button "load div_content": Ok.

Step 2 - Execute function f()
Execute function from inside iframe: Ok.
Execute function from outside iframe: Ok.

Step 3 - View location.href of iframe: Ok.
From inside: Ok.
From outside: Ok.

And we go to the beginning:

Step 1 - Reload div_content: Ok.

Step 2 - Execute function f()
Execute function from inside iframe: Ok.
Execute function from outside iframe: ERROR.

Step 3 - View location.href of iframe
From inside: Ok.
From outside: ERROR.


The second time we load the div_content with the same code, the function f() inside iframe is not accessible.

If we load the div_content with the same code changing the name of iframe (idFrame, idFrame2, idFrame3,...) the first load works fine, but if we reload an ancient iframe the function inside iframe is not accessible.

Init.html
-----------------------------------------------------------------------------
[HTML]<html>
<head>
<title>Init</title>
</head>
<body>
<input type="button" value="Step 1- load div_content" onClick="document.getElementById('div_content').in nerHTML='<iframe id=\'idFrame\' name=\'idFrame\' src=\'iframe.html\' ></iframe>'" ><br>
<input type="button" value="Step 2 - execute function f() inside iframe" onClick="window.frames['idFrame'].f()" ><br>
<input type="button" value="Step 3 - view location " onClick="alert(window.frames['idFrame'].location.href);" ><br>
<div id="div_content">
</div>
</body>
</html>[/HTML]


iframe.html
-----------------------------------------------------------------------------
[HTML]<html>
<head>
<title>Iframe</title>
<script type="text/javascript">
function f()
{
alert('Fucntion f().');
}
</script>
</head>
<body>
<input type="button" value="Step 2 - execute function f() inside iframe" onClick="f()" >
<input type="button" value="Step 3 - view location" onClick="alert(self.location)" >
</body>
</html>[/HTML]
CAG CAG is offline
Newbie
 
Join Date: Oct 2006
Posts: 4
#4: Oct 22 '07

re: Iframe submit issue in Firefox


Quote:

Originally Posted by Simon88

I have a very similar problem, i think this is an Firefox bug. I have posted it an i am waiting for an answer...

We have the next situation:
- page with an iframe.
- the iframe contents a function called f().

We want to load the iframe and execute a function inside iframe from outside iframe.


We follow the next steps:

Step 1 - Button "load div_content": Ok.

Step 2 - Execute function f()
Execute function from inside iframe: Ok.
Execute function from outside iframe: Ok.

Step 3 - View location.href of iframe: Ok.
From inside: Ok.
From outside: Ok.

And we go to the beginning:

Step 1 - Reload div_content: Ok.

Step 2 - Execute function f()
Execute function from inside iframe: Ok.
Execute function from outside iframe: ERROR.

Step 3 - View location.href of iframe
From inside: Ok.
From outside: ERROR.


The second time we load the div_content with the same code, the function f() inside iframe is not accessible.

If we load the div_content with the same code changing the name of iframe (idFrame, idFrame2, idFrame3,...) the first load works fine, but if we reload an ancient iframe the function inside iframe is not accessible.

Init.html
-----------------------------------------------------------------------------
[HTML]<html>
<head>
<title>Init</title>
</head>
<body>
<input type="button" value="Step 1- load div_content" onClick="document.getElementById('div_content').in nerHTML='<iframe id=\'idFrame\' name=\'idFrame\' src=\'iframe.html\' ></iframe>'" ><br>
<input type="button" value="Step 2 - execute function f() inside iframe" onClick="window.frames['idFrame'].f()" ><br>
<input type="button" value="Step 3 - view location " onClick="alert(window.frames['idFrame'].location.href);" ><br>
<div id="div_content">
</div>
</body>
</html>[/HTML]


iframe.html
-----------------------------------------------------------------------------
[HTML]<html>
<head>
<title>Iframe</title>
<script type="text/javascript">
function f()
{
alert('Fucntion f().');
}
</script>
</head>
<body>
<input type="button" value="Step 2 - execute function f() inside iframe" onClick="f()" >
<input type="button" value="Step 3 - view location" onClick="alert(self.location)" >
</body>
</html>[/HTML]


I got solution to my problem,

In my case I need to gave unique name to iframe each time.

With this dynamically given name I'm able to access the form loaded in iframe each time.

Thanks for support. :)
Reply