what do <form action=“#”> and <form method=“post” action=“#”> do?

前端 未结 4 1455

I\'m reading a book on html development (which I\'m fairly new at) and despite the fact that the book just had its 1st publishing one month ago (Nov. 2011), the author is an

4条回答
  •  野性不改
    2020-11-27 12:39

    action="" will resolve to the page's address. action="#" will resolve to the page's address + #, which will mean an empty fragment identifier.

    Doing the latter might prevent a navigation (new load) to the same page and instead try to jump to the element with the id in the fragment identifier. But, since it's empty, it won't jump anywhere.

    Usually, authors just put # in href-like attributes when they're not going to use the attribute where they're using scripting instead. In these cases, they could just use action="" (or omit it if validation allows).

提交回复
热议问题