dongshu4755 2019-05-22 05:34
浏览 51

如何自动重定向php js

How can I redirect automatically

when visitor come check if mousemove or keypress or mouseclick or scrolling & redirect to $activitly if not send they to other url

checking methods:

  1. mousemove
  2. mouseclick
  3. key press
  4. scrolling

start checking time when page reload ..redircet checking time is 15 scnds this is code

$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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度