Complete code of countdown dynamic display effect realized by pure jsp
- 2021-08-31 08:47:46
- OfStack
This paper describes the code of countdown dynamic display effect realized by pure jsp. Share it for your reference, as follows:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<div id="showTimes"></div>
<%
long current_time=System.currentTimeMillis();
long end_time=1337875200000l;
long time=end_time-current_time;
%>
<script>
var second = <%= time / 1000%>; // Seconds remaining
// Write 1 Methods that specify seconds as days
var toDays = function(){
var s = second % 60; // Seconds
var mi = (second - s) / 60 % 60; // Minutes
var h = ((second - s) / 60 - mi ) / 60 % 24; // Hours
var d = (((second - s) / 60 - mi ) / 60 - h ) / 24 // Days
return " Remaining: " + d + " Days " + h + " Hours " + mi + " Minutes " + s + " Seconds ";
}
// And then write 1 Timer
window.setInterval(function(){
second --;
document.getElementById("showTimes").innerHTML = toDays ();
}, 1000);
</script>
I hope this article is helpful to everyone's JSP programming.