submitting a GET form with query string params and hidden params disappear

前端 未结 10 682
庸人自扰
庸人自扰 2020-11-22 02:22

Consider this form:

10条回答
  •  忘了有多久
    2020-11-22 03:13

    In HTML5, this is per-spec behaviour.

    See http://www.w3.org/TR/2011/WD-html5-20110525/association-of-controls-and-forms.html#form-submission-algorithm

    Look at "4.10.22.3 Form submission algorithm", step 17. In the case of a GET form to an http/s URI with a query string:

    Let destination be a new URL that is equal to the action except that its component is replaced by query (adding a U+003F QUESTION MARK character (?) if appropriate).

    So, your browser will trash the existing "?..." part of your URI and replace it with a new one based on your form.

    In HTML 4.01, the spec produces invalid URIs - most browsers didn't actually do this though..

    See http://www.w3.org/TR/html401/interact/forms.html#h-17.13.3, step four - the URI will have a ? appended, even if it already contains one.

提交回复
热议问题