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

JavaScript實(shí)現(xiàn)頁(yè)面無(wú)操作倒計(jì)時(shí)退出

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

項(xiàng)目前端頁(yè)面需要實(shí)現(xiàn),頁(yè)面沒(méi)人操作進(jìn)入倒計(jì)時(shí),以下為前端代碼實(shí)現(xiàn)。

//設(shè)置(倒計(jì)時(shí)功能)開(kāi)關(guān)
var _mouseActiveListener_flag = true;

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

count:倒計(jì)時(shí)總數(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();
 });
 };

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

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論