I have a problem with catching an error in Netscape.
I have a small makeshift puesdo-security script that runs in a .js on our intranet (code below). When they log on users are allocated a group (i.e "accounting"
and this is set in a javascript variable in one of the frames. To prevent users accessing reports without logging on the script looks for this variable (before validating this group name against those with permissions (passed from the report itself via a string - i.e checkSecurity("accounting","developer"
).
If the variable doesn't exist javascript gives the 'is null or not an object' error which is caught and the user redirected to a blank screen with an error message.
The problem is that the below script works fine with IE 5 which luckily enough most of my users have. However - some still want Netscape and this doesn't like the 'try' bit. I could use the window.onError to catch the missing variable error but I'm loathe to as I don't want every javascript error possible kicking the user out with the 'you can't access...' message. I know Jared posted a message on this subject about a year ago but I wondered if anyone had any ideas...
Many thanks,
Joe.
// security function
function checkSecurity() {
var noAccess = 0;
var vWho;
var listOfWhoV = checkSecurity.arguments;
var listOfWhoC = listOfWhoV.length;
// catch people trying the URL
try {
vWho = top.index.user_id.vGroup;
} catch(e) {
alert("You cannot access this report from outside the intranet"
document.location="/blank.html";
return false();
}
// loop thru all groups
for (var i = 0; i < listOfWhoC; i++) {
// prevent unauthorised internal access, give all to developer
switch (vWho) {
case "developer": noAccess = 0; break;
default: switch (listOfWhoV) {
case vWho: noAccess = 0; break;
default : noAccess = 1;
}
}
}
if (noAccess==1){document.location="/blank.html"; alert("you do not have permissions to run this report"
; return false;}
}
I have a small makeshift puesdo-security script that runs in a .js on our intranet (code below). When they log on users are allocated a group (i.e "accounting"
If the variable doesn't exist javascript gives the 'is null or not an object' error which is caught and the user redirected to a blank screen with an error message.
The problem is that the below script works fine with IE 5 which luckily enough most of my users have. However - some still want Netscape and this doesn't like the 'try' bit. I could use the window.onError to catch the missing variable error but I'm loathe to as I don't want every javascript error possible kicking the user out with the 'you can't access...' message. I know Jared posted a message on this subject about a year ago but I wondered if anyone had any ideas...
Many thanks,
Joe.
// security function
function checkSecurity() {
var noAccess = 0;
var vWho;
var listOfWhoV = checkSecurity.arguments;
var listOfWhoC = listOfWhoV.length;
// catch people trying the URL
try {
vWho = top.index.user_id.vGroup;
} catch(e) {
alert("You cannot access this report from outside the intranet"
document.location="/blank.html";
return false();
}
// loop thru all groups
for (var i = 0; i < listOfWhoC; i++) {
// prevent unauthorised internal access, give all to developer
switch (vWho) {
case "developer": noAccess = 0; break;
default: switch (listOfWhoV) {
case vWho: noAccess = 0; break;
default : noAccess = 1;
}
}
}
if (noAccess==1){document.location="/blank.html"; alert("you do not have permissions to run this report"
}