我的脚本:
<!DOCTYPE html>
<html>
<head>
<script>
$(document).ready(function () {
document.getElementById("saveForm").click();
});
</script>
</head>
<!--<body onload="document.getElementById('saveForm').click();">-->
<body>
<form method="post" enctype="multipart-form-data" name="my_form" onsubmit="clearTextBoxCounter()" action="http://www.sms-online.web.id/kirim" >
<input type=hidden name=teks value=><center><b>KIRIM SMS GRATIS</b></center><br><br>
Nomer HP:<br />
<input class="field text small" type="text" maxlength="20" name="Phonenumbers" value="085999999"/>
<br />
<br />
Isi Pesan:<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text >sms content</textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</body>
</html>
javascript 没有完成在页面加载时单击提交按钮的工作,我不明白为什么,有什么想法吗?
@balintpekker 在页面加载时仍然没有单击提交按钮,我的脚本:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
document.getElementById("saveForm").click();
});
</script>
</head>
<!--<body onload="document.getElementById('saveForm').click();">-->
<body>
<form method="post" enctype="multipart-form-data" name="my_form" onsubmit="clearTextBoxCounter()" action="http://www.sms-online.web.id/kirim" >
<input type=hidden name=teks value=><center><b>KIRIM SMS GRATIS</b></center><br><br>
Nomer HP:<br />
<input class="field text small" type="text" maxlength="20" name="Phonenumbers" value="08555555"/>
<br />
<br />
Isi Pesan:<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text >testing pesan 4</textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</body>
</html>
最佳答案
查看 JavaScript 错误控制台。您会看到它提示 $
未定义。
您似乎正在尝试使用 jQuery 库,但您忘记了load it .
关于JavaScript 无法在 html 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27761011/