Page is a not externally linkable
lucy24 - 10:13 pm on Oct 11, 2012 (gmt 0)
Exactly that would happen if the variable "pagenum" is undefined or null, would it not? Sure it has a value always?
That's what I wondered about. If showClick is called in the intended way, it will always have a numerical value, explicitly identified as 1 through 4. Even 5 doesn't occur in real life; I just use it in my test page so I can pull it out of logs more easily. But if the browser is trying to call the function on its own, then no value has been passed to it. I guess a "null" or "undefined" value doesn't count as an unequivocal error, so the function still executes.
You could validate the input (pagenum) to make sure it's not undefined or null
Yes, that seems like the easiest escape route.
if (pagenum != 1 && pagenum != 2 ) ... et cetera.
Solves the problem of "how to prevent it" even if it doesn't answer the underlying "why" ;)