日期:2014-05-16  浏览次数:20391 次

jsp实现半小时的倒计时页面
<%@ page language="java"  pageEncoding="UTF-8"%>
<div id="leftTime"></div>
<script>
	
	var leftTime = <%=Integer.parseInt("1800")%>;
	
	function showLeftTime(){
		var leftMinutes = parseInt(leftTime/60);
		var leftSeconds = parseInt(leftTime%60);
		
		if(leftTime < 0){
			clearInterval(timer);
			document.location.href = document.location.href;
			//document.getElementById('leftTime').innerHTML = '';
			
		}else{
			document.getElementById('leftTime').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如未选择付费方式 ,剩余时间小于5分钟将不允许支付 ,剩余时间:'+leftMinutes+'分'+leftSeconds+'秒';
		}
		leftTime--;
	}
	
	
	var timer = setInterval('showLeftTime()',1000);
	
</script>