(!stay) in a tutorial

D

Dung Ping

I came across following code in a tutorial. I originally thought the
word 'stay' in (!stay) was not important, and could be replaced by
another word. The negation mark (!) was doing the whole work. But when
replacing the 'stay' with another word, such as 'remain', the if
conditional did not work.

As far as I know, 'stay' is not a reserved word, and is not defined in
the code, either. How come it is a must?

<html>
<head>
<script type='text/javascript'>

var stay=confirm ("The following site contains appalling material
suitable only for webmasters. Please 'ok' to enter, 'cancel' to exit
immediately!")

if (!stay){
window.location="http://www.yahoo.com"
}
</script>
</head>
<body>
Appalling material here
</body>
</html>

The web page is in:
http://www.pinyinology.com/learning/stay.html

Thanks.
Dung Ping
 
B

Baconbutty

stay is not a reserved word

When you say you replaced "stay", did you replace it in both:-

if (!remain)...

AND

var remain=confirm(...

?
 
M

McKirahan

Dung Ping said:
I came across following code in a tutorial. I originally thought the
word 'stay' in (!stay) was not important, and could be replaced by
another word. The negation mark (!) was doing the whole work. But when
replacing the 'stay' with another word, such as 'remain', the if
conditional did not work.

As far as I know, 'stay' is not a reserved word, and is not defined in
the code, either. How come it is a must?

<html>
<head>
<script type='text/javascript'>

var stay=confirm ("The following site contains appalling material
suitable only for webmasters. Please 'ok' to enter, 'cancel' to exit
immediately!")

if (!stay){
window.location="http://www.yahoo.com"
}
</script>
</head>
<body>
Appalling material here
</body>
</html>

The web page is in:
http://www.pinyinology.com/learning/stay.html

Thanks.
Dung Ping

Did you replace all (both) uses of "stay"?

var stay

if (!stay){
 
D

Dung Ping

I was stupid and careless. I thought I had discovered a miracle word,
and posted a stupid question to the forum. The 'stay' was there. I
simply didn't see it.

Thanks a lot and I am sorry for the annoyance.

Dung Ping
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top