Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eval question

Status
Not open for further replies.

shmmeee

Programmer
Apr 17, 2001
104
0
0
GB
I'm using eval on a users input to turn it into a variable. However if the user enters something that isn't a variable then an error occurs (No such variable or something similar) is there a way to check for this to aviod the error? I have been using
Code:
window.onerror
but there are reasons that I would rather not also if I have to use
Code:
onerror
does it switch itself off again after the script has stopped running or do I have to do some tidying up.

Thanks in advance s-)
 
This code snippit should get you close.

<script language=&quot;JavaScript&quot;>
if(typeof x == &quot;undefined&quot;)
{
alert('Not a Variable');
}
</script>

Bill Guttman - katun@mindspring.com
Great JavaScript tips at
 
Sorry, is x the string the user has inputted or eval(user_string)?

I've tried both and still can't get it to work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top