PRB: JScript "Type Mismatch" Error Occurs After Upgrade to JScript Version 5.5 (271192)
The information in this article applies to:
- Microsoft Active Server Pages 2.0
This article was previously published under Q271192 SYMPTOMS
When a Web server has version 5.5 of the JScript.dll installed, the following error may occur when an Active Server Pages (ASP) page is viewed in a Web browser:
Microsoft JScript runtime (0x800A000D)
Type mismatch
/vdir/page.asp, line 13
Note that the actual line number may vary.
CAUSE
In JScript 5.5, the Date object contains the date in a different format than previous versions of the JScript.dll file did. Existing code that uses the Date object may require the date in the older format, which may cause an error when the date is received in the new format. For example, the ExpiresAbsolute property of the ASP Response object cannot process the new date format. This error can be caused by the following line of code, which is generated by the Commerce Foundation Wizard:
Response.ExpiresAbsolute = new Date(new Date().setYear(1980)).toLocaleString();
RESOLUTION
You can follow these steps to resolve this problem:
- Add the following JScript server-side code to the top of your ASP page, and then browse to the page in your Web browser to reproduce the error:
<%@ Language=JavaScript %>
<%
function ZeroPad(n)
{
if (n < 10)
return "0" + n;
return n;
}
Date.prototype.toUsaString = function()
{
return (ZeroPad(this.getMonth() + 1)) + "/" +
ZeroPad(this.getDate()) + "/" +
ZeroPad(this.getFullYear()) + " " +
ZeroPad(this.getHours()) + ":" +
ZeroPad(this.getMinutes()) + ":" +
ZeroPad(this.getSeconds());
}
Response.ExpiresAbsolute = new Date(new Date().setYear(1980)).toLocaleString();
%>
- Change the line of code that causes the error from
Response.ExpiresAbsolute = new Date(new Date().setYear(1980)).toLocaleString();
to:
Response.ExpiresAbsolute = new Date(new Date().setYear(1980)).toUsaString();
NOTE: The toUsaString function can be modified, if necessary, to reflect different date formatting needs.
MORE INFORMATION
Prior to version 5.5, JScript's Date object always contained a date in mm/dd/yyyy format. Additional functionality was introduced with JScript version 5.5 to enable this object to contain the date in a localized format, such as "Thursday, August 10, 2000." This format is not recognized by Response.ExpiresAbsolute.
Modification Type: | Major | Last Reviewed: | 8/15/2001 |
---|
Keywords: | kbDSupport kbprb KB271192 |
---|
|