HTML/Xhtml
主页 > 网页 > HTML/Xhtml >

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

2023-07-03 | 佚名 | 点击:

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

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>

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

原文链接:
相关文章
最新更新