<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'js3.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script src="js/jquery-1.2.6.js"></script>
<script type="text/javascript">
go = function(){
location = "http://www.baidu.com";
}
var time = 5;
function show(){
time--;
document.getElementsByTagName("span")[0].innerText = time;
if(time == 0)
{
location = "http://www.baidu.com";
}
}
setInterval("show()",1000);
</script>
</head>
<body>
<div>
<span>5</span>秒后自动跳转到百度 <input type="button" value="提交" onclick="go()"/>
</div>
</body>
</html>
本文介绍了一个使用JSP实现的简单页面,该页面通过JavaScript定时器实现了自动跳转功能。页面加载后会显示倒计时,并在设定的时间结束后自动导航至指定URL。此外,还提供了手动跳转按钮。

1万+

被折叠的 条评论
为什么被折叠?



