admin管理员组文章数量:1402138
I am getting the error when using getElementById()
. I won't post the entire program since it's a homework assignment, but when I ment out this line of code I don't get any more syntax errors. What should I be looking for in the rest of the code that could have caused the problem?
document.getElementById("bugOne").style.left = xPos + "px";
Also- what is an "Invalid Argument" error usually caused by?
I am getting the error when using getElementById()
. I won't post the entire program since it's a homework assignment, but when I ment out this line of code I don't get any more syntax errors. What should I be looking for in the rest of the code that could have caused the problem?
document.getElementById("bugOne").style.left = xPos + "px";
Also- what is an "Invalid Argument" error usually caused by?
Share Improve this question asked Apr 8, 2013 at 23:04 user2234760user2234760 1433 gold badges5 silver badges16 bronze badges 02 Answers
Reset to default 4"Invalid Argument"
is going to be a runtime error, not a syntax error. Don't jump to getElementById()
as the culprit - you have a lot going on in one line of code. For debugging, it's useful to break up plex statements:
var bugOne = document.getElementById("bugOne");
var left = xPos + "px";
bugOne.style.left = left;
In IE8, if you set a bad value on a style property, you get an "Invalid argument"
error. I'm guessing xPos
contains either undefined
or NaN
. Set a breakpoint in your debugger and examine the value of xPos
.
Please post the the code (HTML and JS) for xPos variable and for bugOne, from definition to usage, as that might make your question easier to answer.
Also, are you using jQuery? If not, why not?
This page (linked) doesn't explain what "invalid argument" means, but it shows areas where it most likely occurs.
本文标签:
版权声明:本文标题:What is the meaning of "Invalid Argument" and what causes this error when debugging JavaScript in Internet Exp 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744343269a2601606.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论