JavaScript to Submit Page After 30 Seconds

后端 未结 3 683
花落未央
花落未央 2021-01-17 01:29

I am looking for a JavaScript to submit a page after 30 seconds from when the page is loaded. Does jQuery offer this functionality or does someone have regular javascript f

相关标签:
3条回答
  • 2021-01-17 02:20

    Using setTimeout you can achieve this by having a callback function which can submit a form for you (I presume that is what you mean by saying to 'submit a page')

        <script>
        setTimeout(function() {
            document.myform.submit();
        }, 30000);
        </script>
    

    That will submit the form with the name 'myform' after 30 seconds the page has been loaded.

    0 讨论(0)
  • 2021-01-17 02:23

    Use the setTimeout function.

    0 讨论(0)
  • 2021-01-17 02:30

    You submit a form, not a page. You don't need jQuery to do that.

    <form id="foo">
        // etc.
    </form>
    
    <script>
        function doSubmit() { document.getElementById('foo').submit(); }
        setTimeout(doSubmit, 30000);
    </script>
    
    0 讨论(0)
提交回复
热议问题