JavaScript Implementation page no operation Countdown exit _javascript Tips

Source: Internet
Author: User

Project front-end page needs to be implemented, the page no one to operate into the countdown, the following is the front-end code implementation.

Set (Countdown function) switch
var _mouseactivelistener_flag = true;

Beforecount: Trigger countdown interval (in milliseconds)

Count: Countdown total (in seconds)

var mouseactivelistener = function (Beforecount, count, callback) {//config var __countdown_html = ' <div id= ' __tt ' s Tyle= "Position:fixed;top:110px;right:10px;z-index:1000;color: #eee; font-size:25px;"
 ></div> ';
define var target = null, _t = NULL, _TC = NULL;
  var target_countdown = function (__count) {if (__count >= 0) {target.innerhtml = __count + ' seconds after exit ';
  _TC = settimeout (function () {Target_countdown (__count);
  }, 1000);
  else {callback ();
 } __count--; }, _t_exec = function () {return settimeout (function () {if (_mouseactivelistener_flag) {target = Ne.dom.createE
   L (__countdown_html);
   Document.body.appendChild (target);
  Target_countdown (count);
 }}, Beforecount);
  }, _t_clear = function () {cleartimeout (_t);
  Cleartimeout (_TC);
  Target.parentElement.removeChild (target);
  $ (target). Remove ();
 target = null;
 };
 exec _t = _t_exec ();
  Document.addeventlistener (' click ', Function () {_t_clear ();
_t = _t_exec (); });

 };
After the operation, explained: After 5 seconds (5000) does not operate the state to trigger the countdown, the countdown 180 seconds, the concrete view code inside function.
Mouseactivelistener (5000, 180, function () {
 window.location.href = "/home/index";
 });

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.