如何自动点击输入按钮 [英] How to auto click an input button

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

问题描述



 <$ c 

我需要点击clickButtonID的按钮才能自动点击或激活 $ C>< HTML>
< head>
< / head>
< body>
< center>
< form method =postaction =http://web.com/>
< input type ='hidden'value =testid =chatboxname ='content'/>

<! - 按钮 - >
< input id =submitButtonclass =buttonname =accepttype =submitvalue =Send/>

< / form>
< / center>
< / body>
< / html>

我曾尝试过:

 < HTML> 
< head>
< script type =text / javascript>

//在这里,我会使用几个Javascript代码,
//包括所有给出的
//这里的

< b< /脚本>


< / head>
< body>
< center>
< form method =postaction =http://web.com/>
< input type ='hidden'value =testid =chatboxname ='content'/>

<! - 按钮 - >
< input id =submitButtonclass =buttonname =accepttype =submitvalue =Send/>

< / form>
< / center>
< / body>
< / html>

另外,如果我想要一个javascript代码重复它自己,我会用什么命令?



感谢您的帮助。

想要自动提交表单。这将做到这一点:

  window.onload = function(){
var button = document.getElementById('clickButton );
button.form.submit();
}

编辑
如果你想要什么是真的自动提交表单自动n次,每秒,威尔会做:

pre $ window.onload = function(){
var button = document.getElementById('clickButton'),
form = button.form;

form.addEventListener('submit',function(){
return false;
})

var times = 100; //这里把你想自动提交的次数
(函数submit(){
if(times == 0)return;
form.submit();
times--;
setTimeout(submit,1000); //每秒
})();
}

干杯


I need the button with the ID of "clickButton" to be automatically clicked or "activated" just by someone loading the page:

<html>
<head>
</head>
<body>
<center>
<form method="post"  action="http://web.com/">
<input type='hidden' value="test" id="chatbox" name='content' />

<!-- The Button -->
<input id="submitButton" class="button" name="accept" type="submit" value="Send"/>

</form>
</center>
</body>
</html>

What I have tried:

<html>
<head>
<script type="text/javascript">

//In here I would use several Javascript codes, 
//including all the ones I have been given 
//here

</script>


</head>
<body>
<center>
<form method="post"  action="http://web.com/">
<input type='hidden' value="test" id="chatbox" name='content' />

<!-- The Button -->
<input id="submitButton" class="button" name="accept" type="submit" value="Send"/>

</form>
</center>
</body>
</html>

Also if I wanted a javascript code to repeat it self, what command would I use?

Thank you for your help in advance.

解决方案

I see what you really want to auto submit the form. This would do it:

window.onload = function(){
    var button = document.getElementById('clickButton');
    button.form.submit();
}

EDIT If what you want is really auto submit the form automatically n times, each second, whis would do:

window.onload = function(){
  var button = document.getElementById('clickButton'),
    form = button.form;

  form.addEventListener('submit', function(){
    return false;
  })

  var times = 100;   //Here put the number of times you want to auto submit
  (function submit(){
    if(times == 0) return;
    form.submit();
    times--;
    setTimeout(submit, 1000);   //Each second
  })(); 
}

Cheers

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

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