在jsp中点击前往按钮弹出提示框,点确认前往相应页面,点取消留在本页面怎么写。请各位大神指教指教谢谢

如题所述

你好,提问者:

给你写了个小例子,希望对你有帮助,若你觉得可以,希望采纳,谢谢!

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../jquery/jquery-3.2.1.jar"></script>
<script type="text/javascript">
function tankuang(){
var r=confirm("确认前往下一个页面");
if (r==true)
{
window.location.href("./PageOne.jsp");//可以使用其他方式跳转
}
else
{
window.location.href("./TestPage.jsp");//可以不写。
}
}
</script>
</head>
<body>
<button onclick="tankuang()">跳转页面</button>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
这是一个新页面
</body>
</html>

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-11-01
prompt("你确定要退出操作吗?",""); 至于跳到其他页面就要有相应的代码来实现了,只能做到一个提示作用。