HTML点击按钮button跳转页面的四种方法
原创
©著作权归作者所有:来自51CTO博客作者YDFM的原创作品,请联系作者获取转载授权,否则将追究法律责任
这篇文章主要介绍了HTML点击按钮button跳转页面的四种方法,每种方法结合实例代码给大家介绍的非常详细,需要的朋友可以参考下
其实我比较喜欢第一种方法
1 |
< button onclick = "window.location.href='../routeEdit/index.html'" type = "button" id = "add" >新增</ button >
|
正文
方法一:在button标签中加上onclick属性,赋值为Javascript
1 2 3 |
< input type = "button" onclick = 'location.href=("index.aspx")' />//在本页面打开
< input type = "button" onclick = 'window.open("bedzhao.aspx")' />//打开新页面
< button onclick = "window.location.href='../routeEdit/index.html'" type = "button" id = "add" >新增</ button >
|
方法二:触发一个函数跳转
1 2 3 4 5 6 |
<script>
function jump(){
window.location.href= "http://blog.sina.com.cn/mleavs" ;
}
</script>
<input type= "button" value= "我是一个按钮" οnclick=javascript:jump()>
|
方法三:a标签的超链接可以直接嵌套一个button
1 2 3 |
< a href = "https://www.baidu.com/" >
< button >点我跳转到度娘!</ button >
</ a >
|
方法四:表单的action定向提交跳转
1 2 3 |
< form action = "xx.html" method = "post" >
< input type = "button" value = "按钮" >
</ form >
|
还有其他方法,有些方法一些浏览器可能会不支持。