Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handling- Netscape

Status
Not open for further replies.

joezapp

Programmer
Feb 26, 2001
63
GB
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 &quot;developer&quot;: noAccess = 0; break;
default: switch (listOfWhoV) {
case vWho: noAccess = 0; break;
default : noAccess = 1;
}
}
}
if (noAccess==1){document.location=&quot;/blank.html&quot;; alert(&quot;you do not have permissions to run this report&quot;); return false;}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top