Pure JSP implementation of the countdown dynamic display effect complete code _jsp programming

Source: Internet
Author: User

This article describes the implementation of pure JSP countdown dynamic display effect code. Share to everyone for your reference, specific 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%>;//number of seconds//
write a method to set the number of seconds for days
var todays = function  () {
 var s = second% 60;//sec
 var mi = (second-s)/60 60;//min
 var h = ((second-s)/60-mi)/60 % 24; Hours
 var d = (((second-s)/60-mi)/60-h)/24//day return
"remaining:" + D + "days" + H + "hours" + mi + "min" + S + "seconds";
}
Then write a timer
window.setinterval (function () {
 second-;
 document.getElementById ("Showtimes"). InnerHTML = Todays ();
}, 1000);
</script>

I hope this article will help you with JSP program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.