简体   繁体   English

Chrome控制台中的JavaScript未捕获错误

[英]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");

see MDN docs 查看MDN文档

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.

相关问题 未捕获的参考错误:未在Javascript中定义文档(Chrome控制台) - Uncaught reference error: document is not definded in Javascript (Chrome console) Google Chrome JavaScript控制台告诉我“未发现……” - Google Chrome JavaScript Console tells me “Uncaught …” Javascript Chrome控制台错误 - Javascript chrome console error Chrome控制台中的Javascript错误 - Javascript error in the chrome console 未捕获的SyntaxError:意外的令牌实例(使用Chrome Javascript控制台) - Uncaught SyntaxError: Unexpected token instanceof (with Chrome Javascript console) 我的Google Chrome JavaScript控制台中的“未捕获的TypeError:未定义不是函数” - “Uncaught TypeError: undefined is not a function” in my Google Chrome JavaScript console AngularJSJ - 未捕获错误:[$ injector:modulerr](chrome控制台错误) - AngularJSJ - Uncaught Error: [$injector:modulerr] (chrome console error) chrome控制台中的jquery&#39;未捕获的ReferenceError未定义&#39;错误消息 - jquery ' Uncaught ReferenceError not defined' error message in chrome console 为什么在Chrome Dev Console上出现“ Uncaught ReferenceError:未定义$”错误? - Why getting “Uncaught ReferenceError: $ is not defined” error on Chrome Dev Console? Chrome 控制台上的独立“未捕获”警报 - Standalone "Uncaught" Alert on Chrome Console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM