Main Page

Login Page

if (isWin) {
isWin95 = sUserAgent.indexOf(“Win95”) > -1
|| sUserAgent.indexOf(“Windows 95”) > -1;
isWin98 = sUserAgent.indexOf(“Win98”) > -1
|| sUserAgent.indexOf(“Windows 98”) > -1;
isWinME = sUserAgent.indexOf(“Win 9x 4.90”) > -1
|| sUserAgent.indexOf(“Windows ME”) > -1;
isWin2K = sUserAgent.indexOf(“Windows NT 5.0”) > -1
|| sUserAgent.indexOf(“Windows 2000”) > -1;
isWinXP = sUserAgent.indexOf(“Windows NT 5.1”) > -1
|| sUserAgent.indexOf(“Windows XP”) > -1;
isWinNT4 = sUserAgent.indexOf(“WinNT”) > -1
|| sUserAgent.indexOf(“Windows NT”) > -1
|| sUserAgent.indexOf(“WinNT4.0”) > -1
|| sUserAgent.indexOf(“Windows NT 4.0”) > -1
&& (!isWinME && !isWin2K && !isWinXP);
}
if (isMac) {
isMac68K = sUserAgent.indexOf(“Mac_68000”) > -1
|| sUserAgent.indexOf(“68K”) > -1;
isMacPPC = sUserAgent.indexOf(“Mac_PowerPC”) > -1
|| sUserAgent.indexOf(“PPC”) > -1;
}
if (isUnix) {
isSunOS = sUserAgent.indexOf(“SunOS”) > -1;
if (isSunOS) {
var reSunOS = new RegExp(“SunOS (\\d+\\.\\d+(?:\\.\\d+)?)”);
reSunOS.test(sUserAgent);
isMinSunOS4 = compareVersions(RegExp[“$1”], “4.0”) >= 0;
isMinSunOS5 = compareVersions(RegExp[“$1”], “5.0”) >= 0;
isMinSunOS5_5 = compareVersions(RegExp[“$1”], “5.5”) >= 0;
}
}
Example: A Login Page
When creating Web applications, the first page a user sees is the login page. Most login pages have at least
two fields: username and password. The purpose, of course, is to keep unauthorized users out. But what
about those users who don’t meet the minimum browser and system requirements for the application?
They really should not be allowed to log in. The solution that many developers choose is to make a login
page that does browser detection before the user is even able to enter a username, password, or any other
information. For this purpose, the browser and operating system detection script works beautifully.
The first step is to decide the minimum requirements for the Web application. For example, suppose that
the Web application is limited to working on Internet Explorer 5.5 and higher on Windows, Mozilla 1.0
or higher on Unix, and Safari 1.0 or higher on Macintosh (these requirements aren’t exactly realistic, but
make for a good example). Keep in mind a certain unspoken requirement: The browser must support
JavaScript; this must also be checked.
252
Chapter 8
11_579088 ch08.qxd 3/28/05 11:38 AM Page 252


JavaScript EditorFree JavaScript Editor     Ajax Editor


©