Creating a input link button

2019-08-01 07:22发布

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?

标签: html input
3条回答
Root(大扎)
2楼-- · 2019-08-01 07:48

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.

查看更多
在下西门庆
3楼-- · 2019-08-01 07:58

Try this code:

<form>
  <input type="button" value="Read more" class="button" onlick="window.location='testimonials.html'">
</form>
查看更多
一纸荒年 Trace。
4楼-- · 2019-08-01 08:01

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>
查看更多
登录 后发表回答