Well, if you tried to detect if it was undefined, did you try to trace the variable? See what the ikey value really is when you send igid? It could be "NaN".
As for the proper solution, I don't see how this wasn't a proper solution, but I'm sure there is another way to get what you want. You could also do this:
[script]if((ikey=="") || (ikey=="NaN") || (ikey=="undefined")){
dothis....
}else{
dothis....
}[/script]
That way you cover all of your base, if ikey is undefined, NaN, or blank, your if statement will catch it. the "||" act as an OR statement (if this or this or this are true). If you knew that, kool, if not, just tryin to help explain what the code means.
Hope that helps some.
~Brett