Creating a input link button

2019-08-01 07:05发布

问题:

hello all a quick question..

i am building a static html page, and would like to like one page to another using a button, now using a link is the easier option but i would like the effect of a button without any javascript going off..

so i would like to use a input button but it to link to a html page like an tag can href.

i was thinking along the lines of this example but without the js..

<form>
  <input type="button" value="Read more" class="button" onclick="window.location.href='testimonials.html'">
</form>

this doesnt work but i am looking for this functionality?? is it possible?

回答1:

Just submit the form to the URL.

<form action="testimonials.html">
  <input type="submit" value="Read more">
</form>

… but buttons are supposed to do stuff. Links go places. Don't send people mixed messages, use a link.



回答2:

you've misspelled "onclick" :)

EDIT: if you want to avoid javascript, you can create a button-like link with CSS:

<a href="testimonials.html" style="display: inline-block; border: 1px solid #AAA; background-color: #CCC; margin: 5px; width: 100px; cursor: pointer; text-align: center; color: #000; text-decoration: none;">Read More</a>


回答3:

Try this code:

<form>
  <input type="button" value="Read more" class="button" onlick="window.location='testimonials.html'">
</form>


标签: html input