Countdown instance code to prevent refresh reset

Source: Internet
Author: User

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

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.