1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

bug 955 continued: Do not call onsubmit for a BUTTON, either.

Added tricky code for calling submit() from onclick() of BUTTON.
This commit is contained in:
Witold Filipczyk 2007-06-10 19:43:59 +02:00 committed by Witold Filipczyk
parent 820afbee0b
commit ba24e154e2
2 changed files with 15 additions and 1 deletions

View File

@ -1383,7 +1383,21 @@ submit_given_form(struct session *ses, struct document_view *doc_view,
void
delayed_submit_given_form(struct delayed_submit_form *dsf)
{
int button = 0;
struct form_control *fc;
/* Stupid workaround for button's onclick="submit();" */
if (!list_empty(dsf->form->items)) {
fc = (struct form_control *)dsf->form->items.next;
if (fc->type == FC_BUTTON) {
fc->type = FC_SUBMIT;
button = 1;
}
}
submit_given_form(dsf->ses, dsf->vs->doc_view, dsf->form, 0);
if (button)
fc->type = FC_BUTTON;
mem_free(dsf);
}

View File

@ -917,7 +917,7 @@ call_onsubmit_and_submit(struct session *ses, struct document_view *doc_view,
* explicitly tell the ECMAScript code which of them was
* pressed. W3C DOM Level 3 doesn't seem to include such a
* feature. */
if (fc->type != FC_RESET && fc->form->onsubmit) {
if (fc->type != FC_RESET && fc->type != FC_BUTTON && fc->form->onsubmit) {
struct string code;
if (init_string(&code)) {