自动点击功能连续点击提交按钮 [英] Auto click function continuously clicking on submit button

查看:38
本文介绍了自动点击功能连续点击提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上添加了自动点击功能.我只想自动点击提交按钮一次.但我的代码不断点击提交按钮.因此,我的页面会不断自动重新加载.

I have put auto click function on my form. I want to auto click submit button only once. But my code is continuously clicking on submit button. Due to that my page is continuously auto reloading.

我只想点击一次按钮.我该怎么做?

I want to just click once on the button. How can I do that?

<form action="" method="POST">
        <input type="text" size="80" name="url"  value="https://drive.google.com/file/d/<?php echo $_GET['id']; ?>/view"/>
        <input type="submit" id="btn" value="PLAY" name="submit" />
    </form>

<script>
window.onload = function(){
document.getElementById('btn').click();
}
</script>

推荐答案

给出的两个答案都很好,但是用户可以操纵和弄乱这些存储的会话项目,因此允许操纵验证.

The two answers given are good, however users can manipulate and mess with these stored session items and therefore allows for manipulation of validation.

为了避免用户弄乱您的验证,您可以检查表单是否已在 PHP 中发布.这在处理敏感的用户信息时尤为重要.

To avoid users messing with your validation you can check if the form has been posted in PHP. This is especially important when dealing with sensitive user information.

<?php if(!isset($_POST['submit'])) { ?>
<script>
   window.onload =  function ()
    {
        document.getElementById('btn').click();     
    }
</script>
<?php } ?>

这篇关于自动点击功能连续点击提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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