Как автоматически перенаправить php js - PullRequest
0 голосов
/ 22 мая 2019

Как я могу автоматически перенаправить

, когда посетитель придет, проверит, перемещает ли мышь или нажатие клавиши, или щелчок мышью, или прокручивает и перенаправляет на $ activitly, если не отправляет их на другой URL

методы проверки:

  1. mousemove
  2. mouseclick
  3. нажатие клавиши
  4. прокрутка

начало проверки времени при перезагрузке страницы .. время проверки перезапуска15 scnds это код

$aff_array = array("http://www.google.COM",
                  "http://google.fr",
                  "http://google.es");
$random = rand(0, count($aff_array) - 1);
$activitly  = $aff_array[$random];

?>
<!-- HTML code -->
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>

<script language="JavaScript">
function set_interval() {
  //the interval 'timer' is set as soon as the page loads  
  var timeoutMins = 1000 * 1 * 15; // 15 seconds
  var timeout1Mins = 1000 * 1 * 13; // 13 seconds
  itimer=setInterval("auto_logout()",timeoutMins);

}

function reset_interval() {
  var timeoutMins = 1000 * 1 * 5; // 15 seconds 
  var timeout1Mins = 1000 * 1 * 3; // 13 seconds
  //resets the timer. The timer is reset on each of the below events:
  // 1. mousemove   2. mouseclick   3. key press 4. scrolling
  //first step: clear the existing timer
  clearInterval(itimer);
  clearInterval(atimer);
  //second step: implement the timer again
  itimer=setInterval("auto_logout()",timeoutMins);
}


function auto_logout() {
  //this function will redirect the user to the logout script
  window.open('self.location', '_self');
}
</script>

</head>
<body onLoad="set_interval(); document.form1.exp_dat.focus();" onKeyPress="reset_interval();" onmousemove="reset_interval();" onclick="reset_interval();" onscroll="reset_interval();">
</body>
</html>
...