Embed this into the <HEAD> of the document.  You might also want to put it into a small file (detectbrowser.js) and then do 
{{{
<jsp:include page="/detectbrowser.js" flush="true">
}}}

in your page.

{{{
// Detects a browser.  I am not certain if this really works,
// it was taken from http://www.webreference.com/js/tips/010123.html

var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;
var IE  = IE4 || IE5;
var NS  = NS4 || NS6;
var Mac = (navigator.platform.indexOf("Mac") == -1) ? false : true;
}}}

----
[Asser]: Object Navigator can be used for generic environment detection.
!Properties:
{{navigator.appCodeName}} = A code name for the browser\\
{{navigator.appName}}     = Human readable name of the browser\\
{{navigator.appVersion}}  = Some version information about browser\\
{{navigator.language}}    = Language settings\\
{{navigator.platform}}    = Machine / operating system identifier\\
...
!Methods:
{{navigator.javaEnabled()}} = Indicator for the Java support (status)\\
...

Isn't this a bad habit ?
if javascript is not supported your pages will fail. 
After seeing the jspwiki browser detection is only used to support netscape 4.7 but isn't it more likely that javascript is disabled than the user agent being netscape 4.7 ?

In this case it best to define normal stylesheets and only check for netscape 4.7

{{{
html:		DeclareCSS;
javascript:	IF[BrowserIsNetscape47]
javascript:		DeclareNetscapeCSS;
}}}

Assuming that the last one wins.

GeneralSollutions:
# As crossbrowser possible without forks.
# Better to have server-side user-agent header parsing.
# For javascript its better to do object detection e.g: if(someObject.someMethod) someObject.someMethod();
# The user may select his browser/style.
# As a last resort javascript browser detection.

--PhilipVanBogaert