R
Robert Mark Bram
Hi All!
I have checked Windows Script help for the Undefined Data Type. It says I
should be able to do this:
// This method will work
if (typeof(x) == "undefined")
// do something
However, I have found that when I try to get something from Session and
Request that does not exist, the object coming back from each is different
when they should both be undefined.
My simple test:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<html>
<body>
reallyNotThere: "<%= Session("reallyNotThere") %>"<br>
reallyNotThere2: "<%= Request("reallyNotThere2") %>"<br>
<%
var reallyNotThere = Session ("reallyNotThere");
Response.Write("<br>Not there "" + reallyNotThere + """)
if (typeof(reallyNotThere) == "undefined")
{
Response.Write("<br>it is not there!");
}
else
{
Response.Write("<br>it is there");
}
var reallyNotThere2 = Request("reallyNotThere2");
Response.Write("<br>Not there 2 "" + reallyNotThere2 +
""")
if (typeof(reallyNotThere2) == "undefined")
{
Response.Write("<br>it is not there!");
}
else
{
Response.Write("<br>it is there");
}
%>
</body>
</html>
The output:
reallyNotThere: ""
reallyNotThere2: ""
Not there "undefined"
it is not there!
Not there 2 "undefined"
it is there
If
(typeof(reallyNotThere) == "undefined")
is true, so should
(typeof(reallyNotThere2) == "undefined")
Rob

I have checked Windows Script help for the Undefined Data Type. It says I
should be able to do this:
// This method will work
if (typeof(x) == "undefined")
// do something
However, I have found that when I try to get something from Session and
Request that does not exist, the object coming back from each is different
when they should both be undefined.
My simple test:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<html>
<body>
reallyNotThere: "<%= Session("reallyNotThere") %>"<br>
reallyNotThere2: "<%= Request("reallyNotThere2") %>"<br>
<%
var reallyNotThere = Session ("reallyNotThere");
Response.Write("<br>Not there "" + reallyNotThere + """)
if (typeof(reallyNotThere) == "undefined")
{
Response.Write("<br>it is not there!");
}
else
{
Response.Write("<br>it is there");
}
var reallyNotThere2 = Request("reallyNotThere2");
Response.Write("<br>Not there 2 "" + reallyNotThere2 +
""")
if (typeof(reallyNotThere2) == "undefined")
{
Response.Write("<br>it is not there!");
}
else
{
Response.Write("<br>it is there");
}
%>
</body>
</html>
The output:
reallyNotThere: ""
reallyNotThere2: ""
Not there "undefined"
it is not there!
Not there 2 "undefined"
it is there
If
(typeof(reallyNotThere) == "undefined")
is true, so should
(typeof(reallyNotThere2) == "undefined")
Rob