最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What is the meaning of "Invalid Argument" and what causes this error when debugging JavaScript in Internet Exp

programmeradmin6浏览0评论

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 0
Add a ment  | 

2 Answers 2

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论