I know this question has been answered many times but in my case the JavaScript code creates a infinite loop which makes my page load continuously,

```
<script type="text/javascript">
    window.onload = function(){
        document.getElementById('theForm').submit();
    }
</script>

```

I also tried the below one and it doesn't work:

```
<body onload="document.theform.submit()";>

```

The below code does what I need but it's not perfect:

```
<script type="text/javascript">
    window.onload = function(){
        document.getElementById('submit_button').click();
        setTimeout(function(){window.stop();},2500);
    }
</script>

```