The meaning of #
as a URL reference (whether as action
or formaction
attribute value or otherwise) is a reference to the start of the current base document. The base document is the current document, unless a <base href=...>
tag has been set.
What happens depends on the situation. Typically, the browser requests for the page again with a query part in the URL (and the page is loaded again, which may imply that client-side scripts are run), but if the same query had been used earlier, the browser probably uses its cache. Moreover, as the start of the document is referred to, focus on any form element is lost and the page may scroll backwards.
So although #
is fairly common in some coding styles, it is not reliable; its purpose is better achieved using client-side event handlers.
The formaction
attribute has a meaning only for submit buttons. A text input element does not constitute a submit button, even though it may trigger form submission, so here the attribute is ignored.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…