troubleshooting Question

Can't post form within an IFRAME in FireFox

Avatar of jdhoch
jdhoch asked on
Web BrowsersJavaScript
8 Comments1 Solution1453 ViewsLast Modified:
I'm having a problem submitting a form that's in an IFRAME from within FireFox (it works in IE).  From the parent page I can execute javascript in the IFRAME, but the form will not submit.  I've stripped out everything but the bare basics in the samples below.  The IFRAME code (test2.aspx) should trigger the unload event for the <Body> when the form is submitted.  Again, it works correctly in IE, but not in FireFox.

Any ideas?


This is the first page (test.aspx):

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>iframe submit test</title>
<script language="javascript" type="text/javascript">
function goLogin()
      {
                  window.frames.AJAXLogin.submitForm();
      return;      
      }
</script>
</head>
<body>
<iframe name="AJAXLogin" id="AJAXLogin" src="test2.aspx" style="display:none;"></iframe>
<a href="#" onclick="goLogin();return false">GO Test</a>

</body>
</html>


This is the second page (test2.aspx)

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>iframe submit test</title>

<script type="text/javascript">

function submitForm()
      {
      alert("before submit");
      document.myform.submit();
      alert("after submit");      
      }      
</script>
</head>
<body onunload="alert('unload')">

<form name="myform" id="myform" action="test2.aspx" method="post">

<input type="hidden" name="username" id="username" value="abc" />

</form>      
</body>
</html>

ASKER CERTIFIED SOLUTION
neeraj523

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros