Vielleicht kann mal jemand genau erklären warum
action=""
nicht leer sein darf.
Ich habe das irgendwann mal recherchiert. Aber „genau“ ist so eine Sache. :)
In HTML 4.01 ist action=""
gültig, weil der Leerstring ein gültiger URI ist. (Hat glaube ich hier auch schon jemand gesagt.)
- http://www.w3.org/TR/html4/interact/forms.html#h-17.3
RFC 2396:
4.2. Same-document References
A URI reference that does not contain a URI is a reference to the
current document. In other words, an empty URI reference within a
document is interpreted as a reference to the start of that document,
and a reference containing only a fragment identifier is a reference
to the identified fragment of that document. Traversal of such a
reference should not result in an additional retrieval action.
However, if the URI reference occurs in a context that is always
intended to result in a new request, as in the case of HTML's FORM
element, then an empty URI reference represents the base URI of the
current document and should be replaced by that URI when transformed
into a request.
- http://www.ietf.org/rfc/rfc2396.txt
Warum ist der Leerstring in HTML5 ungültig?
Ian Hickson:
Because browsers do weird things with an empty action="" attribute.
- https://www.w3.org/Bugs/Public/show_bug.cgi?id=14215
Zum Beispiel?
Thomas Broyer-2:
Yes, because they're violating the spec too. HTML5 defines the form
submission to violate the RFC 3986 to make it work like IE, FF and
Opera:
http://www.w3.org/TR/html5/forms.html#form-submission-algorithm (step 9)
The comments there (an HTML comment, look at the source of the page) says:
<!-- Don't ask me why. But that's what IE does. It even treats
action="" differently from action=" " or action="#" (the latter
two resolve to the base URL, the first one resolves to the doc
URL). And other browsers concur. It is even required, see e.g.
http://bugs.webkit.org/show_bug.cgi?id=7763
https://bugzilla.mozilla.org/show_bug.cgi?id=297761
-->
- http://python.6.n6.nabble.com/empty-action-attribute-with-forms-in-Google-Chrome-td2212415.html
Die base URL ist wahrscheinlich das hier:
The document base URL of a Document object is the absolute URL obtained by running these substeps:
If there is no base element that has an href attribute in the Document, then the document base URL is the Document's fallback base URL; abort these steps.
Otherwise, the document base URL is the frozen base URL of the first base element in the Document that has an href attribute, in tree order.
- http://www.w3.org/TR/html5/infrastructure.html#document-base-url
Leute, die diese Spezifikationen entwickeln, haben den besten Job.