I want to create an HTML button that will act as a hyperlink: when you click on the button, it should redirect the user to a specific page. I want the button to be as convenient as possible. I would also like the URL to have no additional characters or parameters.
How can I achieve this?
Now I do this:
<form method="get" action="/page2"> <button type="submit">Continue</button> </form> The problem is that a question mark is added to Safari and Internet Explorer at the end of the URL. I need to make sure that there are no additional characters at the end of the URL.
There are two possible solutions to this problem: the use of JavaScript and the design of a hyperlink in the form of a button.
Using JavaScript:
<button onclick="window.location.href='/page2'">Continue</button> But this, of course, requires javascript, and for this reason will not work for screen readers.
The purpose of the hyperlink is to move to another page. Therefore, an attempt to make a button act as a link is an incorrect decision, that is, using a hyperlink and using styles to make it look like a button is not true.
<a href="/page2>Continue</a> Translation of the question “ How to create an HTML button? » @Andrew .