PDA

View Full Version : Function evaluates true rather than executes?


gorilla1
08-12-2002, 10:51 PM
If I want to pass an argument of 1 to a function like so,

a href="javascript:Doit(1);"

rather than the function getting called, the browser displays 'true', presumably evaluating the expression. I know how I can sidestep this, but why does it happen, and is there a proper way to pass an argument like this?

G

adios
08-12-2002, 11:58 PM
Nothing being evaluated; the event (link click) is simply proceeding on to its usual conclusion - loading a new document (the use of the javascript: url doesn't negate this). Use this (pseudo-)protocol in a link and the window will always try to load something, most often seen with window.open(), which returns a window object, loading it as [object Window] - nice page. Try this:

<a href="javascript:void doit(1)">

...to void (eliminate) any possible return value. :)

gorilla1
08-13-2002, 01:19 AM
Ah, ok, thanks, Adios.

G