Reputation: 26418
is it possible to use a button as an hyperlink in html. and it should be working for all the browsers?
Upvotes: 0
Views: 196
Reputation: 11
<form action="file1.php" method="get">
<button type="submit">Submit</button><br>
<button type="submit" formaction="file2.php">Submit to another page</button>
</form>
Upvotes: 0
Reputation: 43243
As a third alternative to the ones suggested here, you could use CSS to style a hyperlink to look like a button. If it works more like a link (goes somewhere, not performs an action), it may be better this way - for example, as far as I know, search engines may not always submit forms, but they would follow a link.
Upvotes: 1
Reputation: 23662
If you want to separate content (html) from behaviour (JavaScript), as oppose to what Darrel suggested I would use:
<form action="http://www.google.com">
<input type="button" value="go to goole" />
</form>
Even thought this is not a form proper, it will work fine, and degrade gracefully when JS is disabled.
Upvotes: 6
Reputation: 6973
Not really a hyperlink per se but you can take the user elsewhere with a button.
<input type="button" value="Go To Google" onclick="window.location='http://google.com'" />
Upvotes: 2