欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript實現(xiàn)頁面無操作倒計時退出

 更新時間:2016年10月22日 08:42:10   作者:尖峰時刻  
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)頁面無操作倒計時退出,具有一定的參考價值,感興趣的小伙伴們可以參考一下

項目前端頁面需要實現(xiàn),頁面沒人操作進入倒計時,以下為前端代碼實現(xiàn)。

//設置(倒計時功能)開關
var _mouseActiveListener_flag = true;

beforecount:觸發(fā)倒計時間隔(單位:毫秒)

count:倒計時總數(shù)(單位:秒)

var mouseActiveListener = function (beforecount, count, callback) {
 //config
var __countdown_html = '<div id="__tt" style="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 + '秒后退出';
  _tc = setTimeout(function () {
   target_countdown(__count);
  }, 1000);
  } else {
  callback();
  }
  __count--;
 }, _t_exec = function () {
  return setTimeout(function () {
  if (_mouseActiveListener_flag) {
   target = Ne.dom.createEl(__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();
 });
 };

//后置操作,解釋:在5秒后(5000)不操作的狀態(tài)下觸發(fā)倒計時,倒計時180秒,具體看View Code里面的函數(shù)。
mouseActiveListener(5000, 180, function () {
 window.location.href = "/Home/Index";
 });

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論