views:

320

answers:

3

For reasons I won't go into we need to click a submit button (as opposed to a plain button) via Javascript.

We do this by getting a handle to the submit button, then executing the .click() method on this button. This works perfectly in FireFox, but in IE6 it only works partially.

The button receives the click, and code associated with the buttons "onClick" event fires (we can observe this by watching the server-side code in the debugger) however, the page never "refreshes" the way it should when clicking a "submit" button.

Since this works in FireFox, we assume it is yet another IE6 bug, but I'm not having any luck finding a work-around. We can't simply refresh the page directly because we need it drawn as though it were drawn from the submit button POST request.

+2  A: 

Wouldn't it be easier to get a reference to the form element and fire the submit event?

var form = document.forms[0];
form.submit();
tj111
As I mention above, we must "click" the button (form.submit won't do).
jasongullickson
A: 

I have the same issue in ASP.net. We must "click" the button because there is more that happens in ASP.net with a form than just the normal .submit() on the form. It has to know which button you clicked so it can match it up to the Click event on the server-side for that button.

Anthony
A: 

Try using setTimeout to delay the click by 1 millisecond.

Anthony