我有兴趣创建一个自动脚本,输入状态,在提交之前显示在文本框中。我希望我可以使用键盘事件进入文本框,因为我认为有一些机器人检测实现键盘事件检查,所以简单textarea.value = "something"
不起作用。
以下是我的代码:
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
</head>
<body>
<textarea id="reply_message"></textarea>
<script>
window.onload = function() {
$('#reply_message').focus();
var e = $.Event('keydown', {
keyCode: 65
});
$('#reply_message').trigger(e);
}
</script>
</body>
</html>
&#13;
我希望输入一封信&#39;在它上面,但它根本不会工作,谁能告诉我如何做到这一点?感谢
答案 0 :(得分:-2)
也许尝试这样的事情:
function onTestChange() {
var key = window.event.keyCode;
// If the user has pressed enter
if (key === 13) {
document.getElementById("txtArea").value = document.getElementById("txtArea").value + "\n*";
return false;
}
else {
return true;
}
}