如何在JavaScript中的页面加载时自动提交表单? [英] How to cause a form to be submitted automatically on page load in JavaScript?

查看:390
本文介绍了如何在JavaScript中的页面加载时自动提交表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能有一个明显的答案,但我对js很新,所以我不知道如何做到这一点。我希望在加载该页面时自动提交页面上的表单,而不需要像按下按钮那样的任何用户操作。怎么做?

This may have an obvious answer, but I am very new to js so I have no idea how to do this. I would like a form on a page to be submitted automatically when that page is loaded without requiring any user action like pressing a button. How to do this?

推荐答案

<form id=lol action="file.php"></form>
<script>document.getElementById('lol').submit();</script>

这篇关于如何在JavaScript中的页面加载时自动提交表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆