按钮js跳转到非表单提交页

时间:2022-05-22 17:36:17

<!DOCTYPE html>

<html>


<head>


<meta
charset="UTF-8">


<title></title>


</head>


<body>


<form
action="http://baidu.com"
method="post">


<input
type="button"
value="跳转到必应"
onclick="jumpto()"/>


<input
type="submit"
value="测试是否能提交表单"
/>


</form>

 


<script>

function jumpto(){

alert('我开始跳了啊?');

window.location.href="http://cn.bing.com/";

}

</script>


</body>

</html>

 

 

PS: 临时给同事写的,其实我给它的建议是写个<a>标签,然后将样式搞得跟button一样,这个比较好.