页面自动跳转,jsp

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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 'zidongtiaozhuan.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">
-->

</head>
<SCRIPT LANGUAGE="JavaScript">
var time
= 4; //时间,秒

function Redirect(){
window.location
= "http://www.baidu.com";
}
var i
= 0;
function dis(){
if(i<time){
document.all.s.innerHTML
= "还剩" + (time - i-1) + "";
i
++;
}
}
timer
=setInterval('dis()', 1000);//显示时间
timer=setTimeout('Redirect()',time * 1000); //跳转

</SCRIPT>
<BODY>
<span id="s"></span>
</BODY>
</HTML>
posted @ 2011-04-28 22:35  生如逆旅一苇以航  阅读(944)  评论(0编辑  收藏  举报