Hi,
I need the users to have at least Internet Explorer 5.5 to be able to log into my site. So, I have written a javascript to check a users browser before they can login and if the check fails, it unhides text within a DIV that tells the user to update their browser, and should disable the login forms.
I have tested this script by upping the browser version required to 6.5 (i only have 6.0), and when my browser fails, it unhides the text between the DIV tags, but does not lock the login forms. Any clues as to why?
Code:
<SCRIPT LANGUAGE="JavaScript1.2">
// Create the function CheckBrowser to disable
//login forms if the function CheckBrowser2
// gives us problems
function CheckBrowser() {
if(!CheckBrowser2()){
document.login_form.username.disabled=true;
document.login_form.password.disabled=true;
document.login_form.login.disabled=true;
document.login_form.reset.disabled=true;
}
else{
// Start with the cursor in the user_name field
document.Form.username.focus();
}
}
function CheckBrowser2() {
// Make sure Internet Explorer is at least version 5.0
// Checks if the user is running Microsoft Windows
if(window.navigator.platform != "Win32"){
document.getElementById("error_browser").style.display = "block";
return false;
//Checks if the user is running Microsoft Internet Explorer
}
if(window.navigator.appName != "Microsoft Internet Explorer"){
document.getElementById("error_browser").style.display = "block";
return false;
}
// Checks if the user is running Microsoft Internet Explorer 5.0 +
appVer = window.navigator.appVersion;
pos = appVer.indexOf("MSIE ");
if(pos != -1){
pos2 = appVer.indexOf(";", pos + 1);
appVersion = appVer.substring(pos + 5, pos2) - 0;
if(appVersion <= 5.5){
document.getElementById("error_browser").style.display = "block";
return false;
}
}
return true;
}
</SCRIPT>
Last edited by kw91 : 08-09-2006 at 10:19 AM.
|