1つの特定のWebページでJavaScriptを使用してフォームを自動送信(ログイン)しようとしています(データはブラウザで再送信されます)。 は、私はこれを使って自分のPC上で非常に簡単に作られたテストフォーム提出する管理:JavaScript - 自動送信フォーム
document.forms["formID"].submit();
をしかし、私はページ上で、それが失敗したことをしようとします。私はGreasemonkeyのページでJavaScriptを実行し、うまくいき、アラートなどを実行しますが、送信は機能しません。 ウェブページは以下のとおりです。http://plusklub.hteronet.ba/Login
は、私はまた、この問題の一番上のコメントから、このコードを使用していた
document.addEventListener("DOMContentLoaded", function(event) {
document.forms["aspnetForm"].submit();
});
コード
のこの部分に負荷のためW8しようとした Auto-Submit Form using JavaScript 失敗は何も起こらないことを意味します。私が試したいくつかのこと:folowing
console.log("test1");
document.addEventListener("DOMContentLoaded", function(event) {
console.log("test2");
});
console.log("test3");
window.onload = function() {
console.log("test4");
}
}
console.log("test5");
var fo=document.getElementById("aspnetForm");
console.log(fo);
var bu=document.getElementsByClassName("button");
console.log(bu);
bu.click();
setTimeout(function(){ console.log("test6"); }, 3000);
出力:
test1helloworld.user.js:13:3
test3helloworld.user.js:17:3
test5helloworld.user.js:22:3
<form name="aspnetForm" method="post" action="/Login?ReturnUrl=http://plusklub.hteronet.ba/" id="aspnetForm">helloworld.user.js:24:3
HTMLCollection [ <input#ctl04_ctl02_btnSubmit.button> ]
ページをロードするのを待っていたので、コードを実行するときにフォームが存在するのですか?エラーはありますか? 「失敗する」とは具体的に何を意味しますか? – charlietfl
@charlietfl、1日目、あなたの時間のために。私の質問を編集する –
イベントハンドラでconsole.log()を追加すると、実際に実行されますか? –