javascript - Invalid argument
I have created a page that loads a table off the screen. When a user hovers over certain help images the table is repositioned to the location of the mouse and is populated with helpful text. The best way to describe it is as an upgraded version of the alt tag.
Everything works fine, unless the user has their mouse over one of the images when the page loads. When that happens it causes a javascript error stating "Invalid argument". When researching the source code on the line specified I find the following line:
AlertBox.style.top = screen_y + mouse_y + offsetAlert_y;
Definitions:
AlertBox is the ID of the table
screen_y is the current scrolling location of the page (I believe this is the problem)
mouse_y is the position of the mouse (y-axis)
offsetAlert_y is the number of pixels I want the alert box to be away from the mouse.
When I check for a valid screen_y before displaying the alert box I get no alert box, but the error never happens.
Thanks for any help.
Abhishek Reddy posted this at 13:43 — 18th December 2004.
He has: 3,348 posts
Joined: Jul 2001
Could I see this in the context of the whole script? I can't spot any error from the one line of code you've given, so it's likely to be elsewhere in the script.
artsapimp posted this at 14:06 — 18th December 2004.
They have: 330 posts
Joined: Apr 2000
Thank you for the reply, but I found a way to bypass this error already. I am sure there is an easier way, but this one worked.
I created a variable boolPageLoad and set it's default value to 0. onLoad I call a function which sets it's value to 1. The popup box does not execute unless the boolPageLoad value is 1.
This has fixed the problem, but I'm not convinced there isn't a easier way to do this.
Thank you again for the reply.
Free Math Test
Fun Math Games
Abhishek Reddy posted this at 02:33 — 19th December 2004.
He has: 3,348 posts
Joined: Jul 2001
A simpler way to do that is to run everything through an init() function called from
That would make more sense if you're familiar with main loops in C or similar.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.