var AL = Request.ServerVariables("http_accept_language");
var ALA = AL.split(",");
%></body></html>
It fails on the line with the split method with error Microsoft JScript runtime (0x800A01B6) Object doesn't support this property or method, but I don't see why.
Name:
Anonymous2009-03-18 9:09
Probably because the object doesn't support that property or method.
Name:
Anonymous2009-03-18 9:30
>>2
No, it's just because ASP doesn't like him. It's there, why wouldn't it be?
function inArray(a, s)
{
for(var i in a)
{
if (s == a[i])
{
return true
}
}
return false
}
/* ParseAcceptedLanguageHeader returns an array of accepted languages, ordered
by decreasing quality. Each element of the array is an array of which the
first element is the main language code (typically from ISO 639-1), the
second element is the subcode (usually either blank or an ISO 3166 two-
letter country code, and the third element is the quality value. */
function ParseAcceptedLanguageHeader()
{
var AL = []
var AL1 = new String(Request.ServerVariables("http_accept_language")).split(",")
for (var n in AL1)
{
AL2 = AL1[n].split(";",2)
AL3 = AL2[0].trim().split("-",2)
Language = AL3[0].trim()
if (AL3[1])
{
SubLanguage = AL3[1].trim()
}
else
{
SubLanguage = ""
}
Quality = 1
if (AL2.length > 1)
{
AL4 = AL2[1].split("=",2)
if (AL4[0].trim().toLowerCase() == "q")
{
Quality = parseFloat(AL4[1])
if (Quality == undefined)
{
Quality = 0
}
}
}
if (Quality > 0) {
AL.push([Language, SubLanguage, Quality])
}
}
AL.sort(function(l,r) { return r[2] - l[2] })
return AL
}
/* DetermineBestLanguage accepts as its only parameter an array of allowed
languages, of which the first element of the array is the default
language if no better match can be made. It compares this list against
the list of allowed languages, and returns the first match if one can
be made. */
function DetermineBestLanguage(AllowedLanguages)
{
AcceptedLanguages = ParseAcceptedLanguageHeader()
for (var i in AcceptedLanguages)
{
for (var j in AllowedLanguages)
{
if (AcceptedLanguages[i][0].toLowerCase() == AllowedLanguages[j].toLowerCase())
{
return AllowedLanguages[j]
}
}
}
return AllowedLanguages[0]
}
/* Redirect based on either the language cookie value, or if that doesn't
exist or is invalid, determine the best language to use from the
Accept-Language header, and set the cookie & redirect based on that */