The countdown instance code that prevents the reset from being refreshed:
Generally speaking, in addition to we explicitly set an expiry date, such as 2018-5-12, like this, generally in the Refresh page when the countdown will be restarted, the following describes the way to prevent this situation, I hope to bring some help to the needs of friends.
The instance code is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>The Name property of the Window object-Ant tribe</title></Head> <Body> <Scripttype= "Text/javascript"> varMaxTime; if(Window.name=="') {MaxTime=7* -; }Else{maxtime=Window.name; } functioncountdown () {if(MaxTime>=0) {minutes=Math.floor (MaxTime/60); seconds=Math.floor (MaxTime% -); Msg="The end of the Countdown is also:"+minutes+"points"+seconds+"seconds"; document.all["Timer"].innerhtml=msg; if(MaxTime==5* -) {alert ('It 's five minutes from the end .'); } --MaxTime; Window.name=MaxTime; } Else{clearinterval (timer); Alert ("the countdown is over."); }} Timer=SetInterval ("Countdown ()", +); </Script> <DivID= "Timer"></Div> </Body> </HTML>
The above code implements our requirements, although the Refresh page will also be reset by the countdown effect. This is achieved because the value of the Window.name property is not changed when the page is refreshed, even if the page loaded with another domain name does not change.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=9088
For more information, refer to: http://www.softwhy.com/javascript/
Countdown instance code to prevent refresh reset