js倒计时,刷新不重记

2016-2-20 liyangweb.com 李杨 JavaScript

js倒计时,实现起来不难,但是刷新往往就重新计算了,如果要实现刷新不重计该如何做呢?有这么几种思路,1:cookie 2:本地缓存 3:window.name ……

前两种比较容易理解,今天我来为大家实现以下使用window.name实现刷新不重计,代码如下:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js倒计时-刷新不重计</title>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var maxtime;
if(window.name==''){ 
    maxtime = 1*60;
    }else{
    maxtime = window.name;
}

function CountDown(){
    if(maxtime>=0){
        minutes = Math.floor(maxtime/60);
        seconds = Math.floor(maxtime%60);
        msg = "距离考试结束还有"+minutes+"分"+seconds+"秒";
//        document.all["timer"].innerHTML = msg;
        document.getElementById("timer").innerHTML = msg;
        if(maxtime == 5*60) alert('注意,还有5分钟!');
        --maxtime;
        window.name = maxtime; 
    }
    else{
        clearInterval(timer);
        alert("考试时间到,结束!");
    }
}
timer = setInterval("CountDown()",1000);
//-->
</SCRIPT>
<div id="timer" style="color:red"></div> 

</body>
</html>

标签: js

评论:

ppfbfq42
约 13 小时前
<a href="http://www.xkf6a16y.com/adidas-nitrocharge-footballe-orange-wei%C3%9F-kurpese">adidas nitrocharge footballe orange wei脽</a> <a href="http://www.hbpewjoe.com/asics-gel-lyte-v-ice-bl%C3%A5-value-obuva">asics gel lyte v ice bl氓 value</a> <a href="http://www.lpdkiia0.com/nike-flyknit-lunar-3-femminile-grigio-bianca-obuvf">nike flyknit lunar 3 femminile grigio bianca</a> <a href="http://www.9iwx2z7l.com/air-jordan-3-retro-wolf-gris-for-venta-texas-obuvf">air jordan 3 retro wolf gris for venta texas</a> <a href="http://www.oz834rgf.com/nike-lebron-12-todas-azul-schuhef">nike lebron 12 todas azul</a> <a href="http://www.50656zme.com/nike-free-run-4.0-femminile-grigio-viola-kurpesd">nike free run 4.0 femminile grigio viola</a>
ppfbfq42 http://www.ppfbfq42.com/
reicsignup
2019-01-21 06:24
<a href="http://www.tinystorygame.com/jordan-flight-23-vert-rouge-scarpee">jordan flight 23 vert rouge</a> <a href="http://www.uctweets.com/air-jordan-retro-13-himmelbl%C3%A5-gr%C3%A5-obuvc">air jordan retro 13 himmelbl氓 gr氓</a> <a href="http://www.brandoncsites.com/air-jordan-retro-5-cielo-blu-scarpea">air jordan retro 5 cielo blu</a> <a href="http://www.carlandcodys.com/nike-zoom-ascention-s%C3%B8lv-brun-chaussuresg">nike zoom ascention s酶lv brun</a> <a href="http://www.creftech.com/nike-free-5.0-femminile-instagram-kurpese">nike free 5.0 femminile instagram</a> <a href="http://www.desksergeant.com/nike-air-huarache-herren-verkauf-obuva">nike air huarache herren verkauf</a>
reicsignup http://www.reicsignup.com/
rodabroad
2019-01-12 12:48
<a href="http://www.cierreplus.com/ua-micro-g-torch-hvid-gr%C3%B8n-butyg">ua micro g torch hvid gr酶n</a> <a href="http://www.gotmarys.com/14-nike-game-ya-tittle-womens-jersey-nfl-san-francisco-49ers-road-white-nflw">14 nike game ya tittle womens jersey nfl san francisco 49ers road white</a> <a href="http://www.nauticabg.com/nike-kobe-5-blu-argento-butye">nike kobe 5 blu argento</a> <a href="http://www.orkansport.com/adidas-x-ace-soccer-rojo-rosado-kurpesc">adidas x ace soccer rojo rosado</a> <a href="http://www.parkcarlton.com/mennns-ralph-lauren-jackets-gr%C3%B8nn-svart-polow">mennns ralph lauren jackets gr酶nn svart</a> <a href="http://www.pilaminates.com/nike-sb-stefan-janoski-max-marine-orange-zone-butyf">nike sb stefan janoski max marine orange zone</a>
rodabroad http://www.rodabroad.com/
energyawnings
2019-01-04 04:12
<a href="http://www.techsrunch.com/nike-air-max-90-rose-guld-kvinders-tops-kurpesf">nike air max 90 rose guld kvinders tops</a> <a href="http://www.tlclease.com/mennns-ralph-lauren-rugbys-r%C3%B8d-lilla-poloz">mennns ralph lauren rugbys r酶d lilla</a> <a href="http://www.beatsbybros.com/adidas-originals-forum-mid-triple-blanc-out-scarpeb">adidas originals forum mid triple blanc out</a> <a href="http://www.dankpixel.com/mens-nike-buffalo-bills-25-lesean-mccoy-limited-royal-blue-rush-drift-fashion-nfl-jersey-nfls">mens nike buffalo bills 25 lesean mccoy limited royal blue rush drift fashion nfl jersey</a> <a href="http://www.givenkface.com/air-jordan-retro-13-enfants-bleu-ciel-scarpeg">air jordan retro 13 enfants bleu ciel</a> <a href="http://www.kasabyd.com/adidas-yeezy-boost-350-triple-svart-specs-obuvd">adidas yeezy boost 350 triple svart specs</a>
energyawnings http://www.energyawnings.com/
covergirlmag
2019-01-02 09:26
<a href="http://www.bhldchauhung.com/air-jordan-2017-lyser%C3%B8d-sort-kurpesc">air jordan 2017 lyser酶d sort</a> <a href="http://www.meknesmorocco.com/nike-tiempo-legend-iv-sg-bianca-oro-butye">nike tiempo legend iv sg bianca oro</a> <a href="http://www.abanigeria.com/air-griffey-max-1-rosa-scarped">air griffey max 1 rosa</a> <a href="http://www.webdatingnews.com/nike-roshe-run-svart-with-bl%C3%A5-tick-schuhea">nike roshe run svart with bl氓 tick</a> <a href="http://www.cropclassix.com/air-jordan-retro-7-cielo-blu-royal-blu-kurpesb">air jordan retro 7 cielo blu royal blu</a> <a href="http://www.chibihentai.com/nike-air-max-tailwind-7-viola-bianca-schuhef">nike air max tailwind 7 viola bianca</a>
covergirlmag http://www.covergirlmag.com/
mwsuperstore
2019-01-02 04:07
<a href="http://www.evolutionecig.com/nfl-mohamed-sanu-womens-limited-red-jersey-12-atlanta-falcons-nike-rush-drift-fashion-nflr">nfl mohamed sanu womens limited red jersey 12 atlanta falcons nike rush drift fashion</a> <a href="http://www.georginabauer.com/nike-mercurial-superfly-blue-lagoon-opening-skoa">nike mercurial superfly blue lagoon opening</a> <a href="http://www.bootsoffprice.com/adidas-superstar-infant-red-sneakere">adidas superstar infant red</a> <a href="http://www.theprintjobs.com/jordan-4-lyser%C3%B8d-and-hvid-kurpesa">jordan 4 lyser酶d and hvid</a> <a href="http://www.dbajournal.com/nike-lebron-ambassador-9-womens-purple-silver-sneakerb">nike lebron ambassador 9 womens purple silver</a> <a href="http://www.procomedian.com/nike-free-rn-white-womens-health-shoesg">nike free rn white womens health</a>
mwsuperstore http://www.mwsuperstore.com/
gracalor
2018-12-31 09:06
<a href="http://www.drnatarajan.com/adidas-tubular-runner-primeknit-sort-guld-obuvg">adidas tubular runner primeknit sort guld</a> <a href="http://www.eysenreich.com/kd-8-enfants-foot-locker-kurpesa">kd 8 enfants foot locker</a> <a href="http://www.jobmetry.com/nike-air-max-2012-hombres-gray-kurpesf">nike air max 2012 hombres gray</a> <a href="http://www.pugdogdev.com/hombres-ralph-lauren-beach-shorts-negro-verde-poloz">hombres ralph lauren beach shorts negro verde</a> <a href="http://www.realtyindubai.com/air-jordan-4-retro-r%C3%B8d-and-hvid-jeep-scarpeb">air jordan 4 retro r酶d and hvid jeep</a> <a href="http://www.safeonproject.com/nfl-matt-schaub-mens-elite-red-jersey-8-atlanta-falcons-nike-home-vapor-untouchable-nfls">nfl matt schaub mens elite red jersey 8 atlanta falcons nike home vapor untouchable</a>
gracalor http://www.gracalor.com/
praiseti
2018-12-31 08:00
<a href="http://www.miendiation.com/new-balance-990-purple-blue-runninge">new balance 990 purple blue</a> <a href="http://www.powfarm.com/adidas-pr%C3%B8dator-uk-salg-schuhea">adidas pr酶dator uk salg</a> <a href="http://www.nongmobacon.com/adidas-battle-pack-projoator-mercadolibre-scarpeb">adidas battle pack projoator mercadolibre</a> <a href="http://www.rentalloka.com/nike-air-max-95-green-spain-shoeso">nike air max 95 green spain</a> <a href="http://www.casamentosweb.com/nike-flyknit-racer-lagoon-blau-label-kurpesb">nike flyknit racer lagoon blau label</a> <a href="http://www.perheopas.com/air-jordan-phase-23-zapatost">air jordan phase 23</a>
praiseti http://www.praiseti.com/
freizeittrend
2018-12-31 04:08
<a href="http://www.cheapcoatsfr.com/nike-free-5.0-cool-gris-vivid-rosado-blanco-kurpesc">nike free 5.0 cool gris vivid rosado blanco</a> <a href="http://www.mylinkstv.com/ray-ban-silver-metal-polarized-aviator-sunglasses-hut-sunglassesc">ray ban silver metal polarized aviator sunglasses hut</a> <a href="http://www.phxfam.com/nfl-mens-nike-pittsburgh-steelers-2-mason-rudolph-stitched-black-anthracite-salute-to-service-player-performance-hoodie-nflr">nfl mens nike pittsburgh steelers 2 mason rudolph stitched black anthracite salute to service player performance hoodie</a> <a href="http://www.shanibazaar.com/nike-kd-8-hunts-hill-sunset-skoa">nike kd 8 hunts hill sunset</a> <a href="http://www.imannequins.com/air-jordan-5-dam%C3%A4nner-gold-sneakerf">air jordan 5 dam盲nner gold</a> <a href="http://www.irentevent.com/nike-flyknit-racer-negro-blanco-sail-kurpesa">nike flyknit racer negro blanco sail</a>
freizeittrend http://www.freizeittrend.com/
cartonpat
2018-12-30 23:16
<a href="http://www.sajromaniuk.com/hermes-bolide-31-etoupe-hermesr">hermes bolide 31 etoupe</a> <a href="http://www.jetsonpress.com/salvatore-ferragamo-burgundy-belt-beltr">salvatore ferragamo burgundy belt</a> <a href="http://www.tentplezier.com/coach-slingback-shoes-coachr">coach slingback shoes</a> <a href="http://www.jeffdiblasi.com/t%C3%AAnis-adidas-porsche-design-p5000-skot">t锚nis adidas porsche design p5000</a> <a href="http://www.puenteconceyu.com/bracelet-skipper-hermes-jewelryr">bracelet skipper hermes</a> <a href="http://www.conmelior.com/mens-fendi-zucca-belt-beltr">mens fendi zucca belt</a>
cartonpat http://www.cartonpat.com/
cubanosocial
2018-12-28 20:31
<a href="http://www.katieirene.com/yeezy-boost-950-marrone-nero-obuvf">yeezy boost 950 marrone nero</a> <a href="http://www.klimafeuer.com/lebron-12-chaussures-colors-schuhee">lebron 12 chaussures colors</a> <a href="http://www.kennethmarrin.com/nike-free-3.0-kvinners-gull-oransje-obuvd">nike free 3.0 kvinners gull oransje</a> <a href="http://www.akashkataria.com/nike-air-force-1-jersey-gull-sport-r%C3%B8d-butye">nike air force 1 jersey gull sport r酶d</a> <a href="http://www.fariselmasu.com/jordan-3-sort-lilla-r%C3%B8d-obuvd">jordan 3 sort lilla r酶d</a> <a href="http://www.cleanopoly.com/nike-structure-19-nero-diamond-kurpesf">nike structure 19 nero diamond</a>
cubanosocial http://www.cubanosocial.com/
hamshrd
2018-12-28 03:53
<a href="http://www.bhcsboosters.com/girls-high-converse-shoesz">girls high converse</a> <a href="http://www.denisgoulart.com/le-coq-sportif-mujeres-zapatos-azul-p%C3%BArpura-schuheb">le coq sportif mujeres zapatos azul p煤rpura</a> <a href="http://www.donggeomdo.com/nike-youth-lee-roy-selmon-limited-black-jersey-tampa-bay-buccaneers-nfl-63-2016-salute-to-service-nflu">nike youth lee roy selmon limited black jersey tampa bay buccaneers nfl 63 2016 salute to service</a> <a href="http://www.ozoessaouira.com/adidas-junior-tubular-shadow-skou">adidas junior tubular shadow</a> <a href="http://www.annomaplexel.com/nike-lunarglide-plus-4-catalog-runningf">nike lunarglide plus 4 catalog</a> <a href="http://www.bringribben.com/under-armour-speedform-slingshot-zapatosu">under armour speedform slingshot</a>
hamshrd http://www.hamshrd.com/
servistylo
2018-12-27 14:34
<a href="http://www.yolandapesto.com/adidas-superstar-bl%C3%A5-r%C3%B8d-hvid-obuve">adidas superstar bl氓 r酶d hvid</a> <a href="http://www.zovailangnews.com/nike-tanjun-rojodit-us-kurpesg">nike tanjun rojodit us</a> <a href="http://www.dijitalbarter.com/nike-kobe-9-kvinders-bl%C3%A5-guld-obuvb">nike kobe 9 kvinders bl氓 guld</a> <a href="http://www.kristyhuston.com/nike-huarache-high-azul-rojo-butya">nike huarache high azul rojo</a> <a href="http://www.malibuj.com/kevin-white-womens-game-orange-jersey-nike-nfl-chicago-bears-alternate-11-nflu">kevin white womens game orange jersey nike nfl chicago bears alternate 11</a> <a href="http://www.notbore.com/nike-zoom-hyperdunk-2011-volt-gr%C3%B8nn-kurpesb">nike zoom hyperdunk 2011 volt gr酶nn</a>
servistylo http://www.servistylo.com/
kokismith
2018-12-27 12:47
<a href="http://www.femmedeguinee.com/nike-huarache-high-womens-gold-pink-skod">nike huarache high womens gold pink</a> <a href="http://www.autosasart.com/how-to-tell-authentic-burberry-scarf-scarfr">how to tell authentic burberry scarf</a> <a href="http://www.pcwolftech.com/new-york-yankees-new-era-baseball-cap-used-hatg">new york yankees new era baseball cap used</a> <a href="http://www.poteputi.com/nike-hypershift-weight-skox">nike hypershift weight</a> <a href="http://www.minsonphoto.com/purple-red-mens-nike-zoom-winflo-3-shoes-shoesb">purple red mens nike zoom winflo 3 shoes</a> <a href="http://www.sandeneuhofer.com/billig-nike-kwazi-action-dam%C3%A4nner-gold-runningb">billig nike kwazi action dam盲nner gold</a>
[url=http://www.kokismith.com/]kokismith[/url]
iumtx7cb
2018-12-27 06:58
<a href="http://www.ehbnzb84.com/nike-foamposite-bleu-orange-butya">nike foamposite bleu orange</a> <a href="http://www.n1jvmtjv.com/kyrie-2-inferno-for-venta-michigan-butyc">kyrie 2 inferno for venta michigan</a> <a href="http://www.r2g427lp.com/nike-air-max-tailwind-6-dam%C3%A4nner-schwarz-leder-scarpeg">nike air max tailwind 6 dam盲nner schwarz leder</a> <a href="http://www.cv9uzx13.com/nike-air-max-thea-royal-blu-bianca-chaussuresb">nike air max thea royal blu bianca</a> <a href="http://www.pqphql39.com/nike-foamposite-wei%C3%9F-rot-butya">nike foamposite wei脽 rot</a> <a href="http://www.8z1143o9.com/adidas-dam%C3%A4nner-springblade-schuhe-schuhee">adidas dam盲nner springblade schuhe</a>
iumtx7cb http://www.iumtx7cb.com/

发表评论:

Powered by emlog 冀ICP备13011830号-1