HTML点击按钮button跳转页面的四种方法

HTML点击按钮button跳转页面的四种方法

其实我比较喜欢第一种方法

button onclick="window.location.href='../routeEdit/index.html'" type="button" id="add" 新增 /button

正文

方法一:在button标签中加上onclick属性,赋值为Javascript

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

方法二:触发一个函数跳转

script function jump(){ window.location.href="http://blog.sina.com.cn/mleavs"; } /script input type="button" value="我是一个按钮" οnclick=javascript:jump()

方法三:a标签的超链接可以直接嵌套一个button

a href="https://www.baidu.com/" button 点我跳转到度娘! /button /a

方法四:表单的action定向提交跳转

form action="xx.html" method="post" input type="button" value="按钮" /form

还有其他方法,有些方法一些浏览器可能会不支持。

结尾

HTML点击按钮button跳转页面的四种方法