从自动保存脚本无法正确保存表单

I have a script that looks for a user to be idle, and when they are for x amount of seconds, it executes a submission of the form the user was on(saving their data, and refreshing the page back to the existing form). For some reason, it is refreshing the page, and NOT submitting the form, causing the form to lose all data in the process :P. Is there something I am missing in the code?

Script Code :

<!-- Set auto save timeout in milliseconds -->
<script type="text/javascript">
attachEvent(window,'load',function(){
  var idleSeconds = 5;
  var idleTimer;
  function resetTimer(){
    clearTimeout(idleTimer);
    idleTimer = setTimeout(whenUserIdle,idleSeconds*1000);
  }
  attachEvent(document.body,'mousemove',resetTimer);
  attachEvent(document.body,'keydown',resetTimer);
  attachEvent(document.body,'click',resetTimer);

  resetTimer(); // Start the timer when the page loads
});

function whenUserIdle(){
        document.project.submit();
        window.location = location.href;
}

function attachEvent(obj,evt,fnc,useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evt,fnc,!!useCapture);
    return true;
  } else if (obj.attachEvent){
    return obj.attachEvent("on"+evt,fnc);
  }
} 
</script> 

Form Code :

<form name="project" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="invoice-form" method="post"  class="invoice-form" role="form" novalidate>