html/css中怎么给按钮加上超链接?

html/css中怎么给按钮加上超链接?下面本篇文章给大家介绍一下给按钮加上超链接的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

html/css给按钮加上超链接

可以使用HTML onclick 事件属性

1、如果让本页转向新的页面则用:

<input type="button" onclick="window.location.href('url地址')">

<button onclick="javascript:window.location.href='url地址';">这是一个按钮</button>

2、如果需要打开一个新的页面进行转向,则用:

<input type="button" onclick="window.open('url')">

3、如果需要返回到上次打开的页面,则用:

<input type="button" onclick="window.history.back()">

更多web前端知识,请查阅 HTML中文网 !!

以上就是html/css中怎么给按钮加上超链接?的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » HTML5 答疑