[英]JavaScript Uncaught Error in Chrome Console
my error is: Uncaught: TypeError: undefined is not a function
. 我的错误是: Uncaught: TypeError: undefined is not a function
。
I am trying to automatically fill a form without hitting submit (I can do that manually, as there is no class or ID on the submit button--then it will re-enter the next set of information after I hit it.) I am also unsure how to do the wait function properly. 我正在尝试自动填写表单而不点击提交(我可以手动完成此操作,因为“提交”按钮上没有类或ID,然后在点击它后它将重新输入下一组信息。)也不确定如何正确执行等待功能。 I have looked it up and tried a few various ways to no avail. 我查了一下,尝试了几种无效的方法。
var qu = ["Do they offer whois privacy for domain registrations? free or at cost?"];
var an = ["Yes, so and so offers domain privacy options for domain registration."];
var q = document.getElementByName("question");
var a = document.getElementByName("answer");
var i = 0;
var delay = 2500;
do {
q.value = qu[i];
a.value = an[i];
i++;
} while (i < qu.length)
Thanks! 谢谢!
getElementByName
不是函数,而是getElementsByName()
,它不返回一个元素,它将返回您NodeList,因此您必须注意这一点。
There is a typo in there: 那里有错字:
document.getElementsByName("question");
document.getElementsByName("answer");
For the wait function you can use: 对于等待功能,您可以使用:
setTimeout( function(){
//do something
}, 500);
This will set a timeout (waiting time) for 500ms 这将设置超时(等待时间)为500ms
see mdn for more info 看到更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.