form.submit() does not get executed when the button is clicked, the same works fine for the anchors

UNCONFIRMED
Unassigned

Status

()

Core
DOM
UNCONFIRMED
11 years ago
9 years ago

People

(Reporter: shafi, Unassigned)

Tracking

({testcase})

Trunk
x86
Windows XP
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

In the button's onclick handler, execution of 'form.submit()' does not result into a full page refresh. I observed this using Firebug. 

But the same onclick handler if I attach to an anchor, form.submit()'s execution will result into a full page refresh. 

Reproducible: Always

Steps to Reproduce:
HTML Testcase

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Form Submit test case </TITLE>
<script type="text/javascript">

function doSubmit()
{
  alert("First Alert");
  document.forms[0].submit();
  alert("Second Alert");
}
</script>
</HEAD>

<BODY>
<form>
  <a id="anchor" onclick="doSubmit()" href="#">anchor</a>
  <button id="button" onclick="doSubmit()">button</button>
</form>
</BODY>
</HTML>



Actual Results:  
click on 'button' :
  1. 'First Alert' comes up
  2. 'Second Alert' comes up.
  3. Full page refresh happens

click on 'anchor'
  1. 'First Alert' comes up
  2. Full page refresh happens
  3. 'Second Alert' comes up.


Expected Results:  
clicking on both 'anchor' & 'button' should result Full page refresh to happen in between the alerts.
(Reporter)

Comment 1

11 years ago
If 'document.forms[0].action =  document.forms[0].action' is placed after 'document.forms.submit()' in the doSubmit() method, then clicking 'anchor' & 'button' result in the correct behavior.
(Reporter)

Comment 2

11 years ago
Created attachment 263615 [details]
HTML test case

HTML test case

Updated

11 years ago
Assignee: nobody → general
Component: General → DOM
Keywords: testcase
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk

Comment 3

11 years ago
This is WORKSFORME on trunk.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → WORKSFORME

Comment 4

11 years ago
Hmm, or maybe not. But <a onclick> and <button onclick> seem to work similarly now.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
(Reporter)

Comment 5

11 years ago
please enable the status bar to see the difference. 

clicking on the 'anchor', results in the following order as expected.
1. Shows 'First Alert'
2. Page refresh in the status bar
3. Shows 'Second Alert'


But clicking on the button throws the 'First Alert' , then 'Second Alert' and then 'Page refresh in the status bar'.
(Reporter)

Comment 6

11 years ago
If I modify the doSubmit method by placing an extra line 
'document.forms[0].action = document.forms[0].action', then click on anchor & link result in the same behavior.

function doSubmit()
{
  alert("First Alert");
  document.forms[0].submit();
  document.forms[0].action = document.forms[0].action;
  alert("Second Alert");
}
Assignee: general → nobody
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.