Javascript 页面自动刷新jsp时自动提交
我有一张自动提交的表格。我希望此页面在自动刷新时自动提交Javascript 页面自动刷新jsp时自动提交,javascript,jsp,Javascript,Jsp,我有一张自动提交的表格。我希望此页面在自动刷新时自动提交 window.onload=function(){ var auto=setTimeout(函数(){autoRefresh();},1000); 函数submitform(){ 警报(“测试”); document.forms[“myForm”].submit(); } 函数autoRefresh(){ clearTimeout(自动); auto=setTimeout(函数(){submitform();autoRefresh();
window.onload=function(){
var auto=setTimeout(函数(){autoRefresh();},1000);
函数submitform(){
警报(“测试”);
document.forms[“myForm”].submit();
}
函数autoRefresh(){
clearTimeout(自动);
auto=setTimeout(函数(){submitform();autoRefresh();},1000);
}
}
在此处插入标题
也许您可以尝试在autorefresh方法中调用SumbitForm()
function autoRefresh(){
clearTimeout(auto);
auto = setTimeout(function(){ submitform(); autoRefresh(); }, 1000);
sumbitForm();
}
我认为
缺少类型
参数。您需要
并尝试通过JS:
document.getElementsByName(“测试”)[0]设置其值代码>顺便说一句,Javascript有setInterval()
,你不需要一直通过setTimeout()
重新安排时间。request.getParameter(“test”)
返回字符串,无需再次使用toString()
。@JohannesJander你能给我一个示例吗?来吧,google只需一分钟。这里有数以百万计的例子。ok tq@johannesjander我必须在你的窗口中设置js?,onload
func窗口。onload=function(){document.getElementsByName(“test”)[0]。value=“testVal”;var auto=setTimeout(function(){autoRefresh();},1000);function submitform(){alert('test'));document.forms[“myForm”].submit();}函数autoRefresh(){clearTimeout(auto);auto=setTimeout(function(){submitform();autoRefresh();},1000);}}准确无误-不要忘记输入类型text