Closed Bug 245859 Opened 20 years ago Closed 19 years ago

form submit() method does not work in setTimeout handler

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED EXPIRED

People

(Reporter: cydergoth, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040316
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040316

function doSubmit() { 
  alert("Submitting...");
  document.forms[0].submit();
  alert("Submit done.");
  }

setTimeout("doSubmit();",300);

This fails in mozilla, works in IE

Reproducible: Always
Steps to Reproduce:
1. setup a timer using setTimeout
2. in the timeout handler try to submit the form
3. watch nothing happen

Actual Results:  
nothing

Expected Results:  
submitted the form (works in IE)
could you please give an example URL were this feature is used, at a real website?
Imho this feature is a violation of my privacy, taking control of my computer.
If there were some vulnerability in JS at the same time, a website could fetch
some data via JS, insert it into a form, and sent it back.
I don´t think Mozilla should copy this "feature" of explorer.
Do you have popup blocking enabled?  If so, this operation would be blocked as a
popup (which it is).
I don't think this should be blocked as a popup. Using form.submit()
programatically is how a lot of advanced widgets work. The particular problem
with this example is that the submit() is inside a timeout handler. It works
outside of the timeout handler as expected.

Whilst I understand the commenta about control, form.submit() is part of the
client side javascript specification.

Cydergoth
Does the form have a target?  If it doesn't, it shouldn't be blocked as a
pop-up.  If its target is a new window, this is a dup of bug 136195.
(In reply to comment #4)
> Does the form have a target?  If it doesn't, it shouldn't be blocked as a
> pop-up.  If its target is a new window, this is a dup of bug 136195.

Thanks for this. This form did not have a target. It was a normal form. If the
forms[0].submit() was executed outside the timeout handler, behaviour was
correct and normal, inside the timeout handler the submit does not work.

Cydergoth
Attached file testcase
This works fine here, using:
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a3) Gecko/20040812
Firefox/0.9.1+
Had the same now with firefox 1.0.2

In the code
<html>
<head>
<title>xxx</title>
<script type="text/javascript">
 	function AbGehts()
 	{
  		document.Sendungsstatus.submit();
 	}
 	window.setTimeout("AbGehts()", 0);
</script>

</head>
<body>...</body></html>

I got the JS error that document.Sendungsstatus has no properties.
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → EXPIRED
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: