JS browser detection

Just wondering if it was possible to load different CSS stylesheets (using javascript) depending on the user’s browser.

I currently have:

<script type=“text/javascript”>
function detectBrowser()
{
var browser=navigator.appName
if(browser==“Microsoft Internet Explorer”)
{<link rel=“stylesheet” type=“text/css” href=“IE.css” />}
if(browser==“Mozilla Firefox”)
{<link rel=“stylesheet” type=“text/css” href=“firefox.css” />}
else
{<link rel=“stylesheet” type=“text/css” href=“uniform.css” />}
}
</script>

in the head section.

if it is possible, am I going about it right? I have set a different coloured background for each css file, so I can tell them apart. Currently, I cant see any of the background colours i’ve specified, so I assume that it didnt load. What am I doing wrong?

Edit:

as an alternative, ive changed the script a bit-

<script type=“text/javascript”>
function detectBrowser()
{
var browser=navigator.appName
if(browser==“Microsoft Internet Explorer”)
{<link rel=“stylesheet” type=“text/css” href=“new.css” />}
else
{<link rel=“stylesheet” type=“text/css” href=“firefox.css” />}
}
</script>

I want it to run a html line, but I dunno if its possible.

Heh, be nice because I’m still trying to learn.
Thanks!