简体   繁体   中英

javascript refresh page 5 seconds after form submit

The form I am working with is an embedded js form, so I don't have direct access to the code.

I am at a tradeshow, and I want the page with the form to refresh 5 seconds after the form has been submitted.

I am using this code, but not getting a refresh. What am I missing?

<script type="text/javascript">
// Reload page 5 seconds after form submission
$("form").onsubmit = setTimeout(function () {
    window.location = "/tradeshow/"; 
    }, 5000);
</script>

Thanks!

You will have to use the location.reload() function for this.

Try this:

<script type="text/javascript">
// Reload page 5 seconds after form submission
$("form").onsubmit = setTimeout(function () {
        location.reload(true); //MODIFICATION
    }, 5000);
</script>

您只能使用元标记来更新用户页面,而无需提交表单:

meta http-equiv="Refresh" content="0.5"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM