RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
javajs倒计时代码,javaweb倒计时

js倒计时代码

html

10年积累的成都网站建设、成都网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有长白免费网站建设让你可以放心的选择与我们合作。

body

离半夜12点还有span id="hour"/span小时span id="min"/span分

/body

script

function countdown() {

var today = new Date();

var h = today.getHours();

var m = today.getMinutes();

h = 23 - h;

m = 59 - m;

m = checkTime(m)

document.getElementById("hour").innerHTML=h;

document.getElementById("min").innerHTML=m;

}

function checkTime(i) {

if (i10) i = "0" + i;

   return i;

}

setInterval("countdown()", 50);

/script

html

javascript代码,在页面实现倒计时,但不随页面刷新而刷新。

实现倒计时很容易,关键是你要求刷新页面,不能停止倒计时

1、使用iframe,嵌入页面,父页上执行js操作,这样子页面刷新后会接着显示倒计时;

2、在后台实现,如使用java的timer类来实现倒计时,前台通过ajax获取倒计时结果,无论前端页面怎么刷新,不会停止倒计时

前端的好写,简单写下,仅供参考

html

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312" /

title无标题文档/title

/head

body onLoad="startCount()" onUnload="fromClose()"

iframe id="myFrame" src="innerPage.html" height="500" width="500"/iframe

/body

/html

script

var timer;

var count=10;

function startCount(){

timer=window.setInterval("myTimeBack()",1000);

}

function myTimeBack(){

myFrame.document.getElementById("myInput").value=count;

count=count-1;

if(count==0)

count=10;

}

function fromClose(){

clearInterval(timer);

}

/script

//嵌入的页面innerPage.html

html

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312" /

title无标题文档/title

/head

body

input type="text" value="" id="myInput" style="width:50"

button onClick="refeshFrame()" style="width:80"refresh/button

/body

/html

script

function refeshFrame(){

this.location.href=this.location.toString();

}

/script

求javascript倒计时代码

script laugnage="javascript"

var temp=10

function oJump()

{

temp-=1

document.getElementById("myclock").innerText=temp;

if(temp==0)

{clearTimeout(obj)}

}

var obj=setInterval("oJump()",1000);

/script

span id="myclock" 10/span

Javascript实例之如何实现时间倒计时

给你一个实例

调用的时候直接写resetTime(这里传入你要倒计时的数字)

本答案出自“我要编程”软件开发师训练平台免费课程。

//单纯分钟和秒倒计时

function resetTime(time){

var timer=null;

var t=time;

var m=0;

var s=0;

m=Math.floor(t/60%60);

m10(m='0'+m);

s=Math.floor(t%60);

function countDown(){

s--;

s10(s='0'+s);

if(s.length=3){

s=59;

m="0"+(Number(m)-1);

}

if(m.length=3){

m='00';

s='00';

clearInterval(timer);

}

console.log(m+"分钟"+s+"秒");

}

timer=setInterval(countDown,1000);

}


网站标题:javajs倒计时代码,javaweb倒计时
标题网址:http://scyingshan.cn/article/hdcghd.html