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="JA VASCRIPT" CODEPAGE="65001 "%>
<html>
<body>
reallyNotThere: "<%= Session("really NotThere") %>"<br>
reallyNotThere2 : "<%= Request("really NotThere2") %>"<br>
<%
var reallyNotThere = Session ("reallyNotTher e");
Response.Write( "<br>Not there "" + reallyNotThere + """)
if (typeof(reallyN otThere) == "undefined" )
{
Response.Write( "<br>it is not there!");
}
else
{
Response.Write( "<br>it is there");
}
var reallyNotThere2 = Request("really NotThere2");
Response.Write( "<br>Not there 2 "" + reallyNotThere2 +
""")
if (typeof(reallyN otThere2) == "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(reallyN otThere) == "undefined" )
is true, so should
(typeof(reallyN otThere2) == "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="JA VASCRIPT" CODEPAGE="65001 "%>
<html>
<body>
reallyNotThere: "<%= Session("really NotThere") %>"<br>
reallyNotThere2 : "<%= Request("really NotThere2") %>"<br>
<%
var reallyNotThere = Session ("reallyNotTher e");
Response.Write( "<br>Not there "" + reallyNotThere + """)
if (typeof(reallyN otThere) == "undefined" )
{
Response.Write( "<br>it is not there!");
}
else
{
Response.Write( "<br>it is there");
}
var reallyNotThere2 = Request("really NotThere2");
Response.Write( "<br>Not there 2 "" + reallyNotThere2 +
""")
if (typeof(reallyN otThere2) == "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(reallyN otThere) == "undefined" )
is true, so should
(typeof(reallyN otThere2) == "undefined" )
Rob
:)
Comment