最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

scripting - JavaScript to Submit Page After 30 Seconds - Stack Overflow

programmeradmin6浏览0评论

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 for this? Thank You

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 for this? Thank You

Share Improve this question asked Nov 6, 2009 at 21:45 FrankFrank 11 silver badge1 bronze badge
Add a ment  | 

3 Answers 3

Reset to default 5

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.

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>

Use the setTimeout function.

发布评论

评论列表(0)

  1. 暂无评论