480reads

onClick event fires when the page loads...view story

Alright, so I'm working on a script, and I'm simply using the following code: document.getElementById("element").onclick = alert("hello"); When I load the page, the alert fires instantaneously. I'm completely stumped. I've checked everything in my not too extensive Javascript file, and it looks fine. What common errors could cause this?

The content of this field is kept private and will not be shown publicly.
To prevent automated spam submissions leave this field empty.
CAPTCHA
Human?
Image CAPTCHA
Enter the characters shown in the image.