Skip to main content
Active reading [<https://en.wikipedia.org/wiki/JavaScript>]. Dressed the naked links.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

As of HTML5, buttons support the formaction attribute. Best of all, no JavascriptJavaScript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • The <button> type must be "submit" (or unspecified), - I couldn't get it working with type "button." Which brings up the point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browserformaction

Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility<button>: The Button element

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no JavaScript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • The <button> type must be "submit" (or unspecified) - I couldn't get it working with type "button." Which brings up the point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: formaction

Browser Support: <button>: The Button element

little edits
Source Link
3CEZVQ
  • 42.9k
  • 11
  • 91
  • 100

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form>   <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button>  </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form>   <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button>  </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form> 

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form> 

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

As of HTML5, buttons support the formaction attribute. Best of all, no Javascript or trickery is needed.

<form> <button formaction="http://stackoverflow.com">Go to Stack Overflow!</button> </form>

Caveats

  • Must be surrounded by <form> tags.
  • <button> type must be "submit" (or unspecified), I couldn't get it working with type "button." Which brings up point below.
  • Overrides the default action in a form. In other words, if you do this inside another form it's going to cause a conflict.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction Browser Support: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Browser_compatibility

Added drawbacks.
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading
edited body
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading
Copy edited. Used the official name of Stack Overflow - see section "Proper Use of the Stack Exchange Name" in <http://stackoverflow.com/legal/trademark-guidance> (the last section).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
Removed w3schools reference.
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading
added 50 characters in body
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading
added 71 characters in body
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading
Source Link
EternalHour
  • 8.7k
  • 6
  • 40
  • 58
Loading