Why can't I submit a form on a page with a URL Fragment?

57 views Asked by At

Stumbled across this today and not sure I understand what's going on.

I have a form on a page; if the page doesn't have a URL fragment I can submit the form to reload the page whether I've changed anything in the form or not.

However, if the page has a URL fragment, I can only submit the form if something in the form has changed from the page's query parameters; if nothing has changed in the form the browser won't let me submit it to reload the page

Fiddle Link: https://codesandbox.io/s/html-forms-forked-4v3zyx?file=/index.html

  1. In the browser window, enter abc into the input field and hit submit; the text should disappear from the input field as the form has submitted and the page has reloaded
  2. Update the URL in the browser to: https://4v3zyx.csb.app/?inp=abc and hit enter
  3. enter abc into the input field and hit submit; the text should disappear from the input field as again the form has submitted and the page has reloaded
  4. Update the URL in the browser to: https://4v3zyx.csb.app/?inp=abc#any-fragment-here and hit enter
  5. enter abc into the input field and hit submit; the text should NOTdisappear from the input field as whatever is going on has prevented the form from being submitted
  6. Change the text to anything else and hit submit, and the page should submit as it did in steps 1 and 3

I can't figure out why - I'm seeing this behaviour in edge, chrome, and firefox - anyone know what's going on?

0

There are 0 answers