フィールドが自動的に入力されるフォームを取得するスクリプトがあり、x秒ごとにフォームを自動的に送信するコードがあります。JavaScriptフォームで「無限」のタブが開きます
問題は、この属性(target = "_ blank")をフォームに追加しましたが、コードを実行して新しいタブを無制限に作成するときにフォームが保持されていたことです。
フォームを処理するための新しいタブを作成し、スクリプトの2回目の実行時に、同じタブを使用して処理ページを更新するようにします。
JavaScriptでこれを行うことはできますか?
<form target="_blank" name="myForm" id="myForm" action="process.asp" method="post">
field 1:<input type="text" name="field1" id="field1" /><br>
field 2:<input type="text" name="field2" id="field2" /><br>
</form>
<script type="text/javascript"> // code which executes the submit of form operation
window.onload=function(){
var auto = setTimeout(function(){ autoRefresh(); }, 100);
function submitform(){
document.forms["myForm"].submit();
}
function autoRefresh(){
clearTimeout(auto);
auto = setTimeout(function(){ submitform(); autoRefresh(); }, 10000);
}
}
</script>`