Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript自动重定向_Javascript_Redirect - Fatal编程技术网

使用javascript自动重定向

使用javascript自动重定向,javascript,redirect,Javascript,Redirect,有人能看出我错在哪里吗?如果人们长时间处于非活动状态,我会尝试将他们重定向到登录页面 <script> var time = new Date().getTime(); $(document.body).bind("mousemove keypress", function(e) { time = new Date().getTime(); }); function refresh() { if(new Date().getTime() - time &

有人能看出我错在哪里吗?如果人们长时间处于非活动状态,我会尝试将他们重定向到登录页面

<script>
 var time = new Date().getTime();
 $(document.body).bind("mousemove keypress", function(e) {
     time = new Date().getTime();
 });

 function refresh() {
     if(new Date().getTime() - time >= 4200000) 
        window.location.href = '/login.cfm'

     else 

         setTimeout(refresh, 10000);
 }

 setTimeout(refresh, 10000);
</script>

var time=new Date().getTime();
$(document.body).bind(“mousemove按键”,函数(e){
时间=新日期().getTime();
});
函数刷新(){
如果(新日期().getTime()-time>=4200000)
window.location.href='/login.cfm'
其他的
设置超时(刷新,10000);
}
设置超时(刷新,10000);
现在好像工作了

试试:

window.location.href

你能告诉我登录页面的位置吗?如果它存在于任何文件夹中,则给出绝对路径。有关更多详细信息,请参阅FOH中的链接,该链接是IIS指向的位置-因此推测/login.cfm可以工作吗?