/    Sign up×
Community /Pin to ProfileBookmark

Question about javascript and CSS

This is my first post here, and I now next to nothing about javascript, so I’m not entirely sure if what I’m trying to do is indeed possible.

I have an html file that uses and external CSS style sheet. However, people using the latest Firefox versions were unable to see the images of my website. So I’ve made another CSS style sheet that works perfectly with the latest versions of Firefox. Now I have 2 external CSS style sheets, one that works with most browsers and one just for Mozilla.

I’m trying to use javascript in my html file to make my page detect the user’s browser and display the apropriate style sheet using an “If… else…” command. Is it possible to direct to a CSS style sheet using javascript?

So far, I have the folowing header:
————————————————————————-

<HEAD>
<script type=”text/javascript” language=”JavaScript” src=”DHTMLMenuExpanderV2.js”></script>
<script type=”text/javascript” language=”JavaScript” src=”EditMeVsample2.js”></script>
<LINK rel=”stylesheet” type=”text/css” href=”DMEVerticalIE.css”>
<LINK rel=”stylesheet” type=”text/css” href=”DMEVertical1.css”>

<script type=”text/javascript”>
function detectBrowser()
{
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
if ((browser==”Netscape”||browser==”Microsoft Internet Explorer”))
{document.getElementById(‘IE’)}
else
{document.getElementById(‘menuSystem’)}
}
</script>


————————————————————————-

I have ommited a part of the header that I don’t think that has anything to do with the problem.

I was trying to set a name for each style sheet, so that I could direct the javascript to them, but I wasn’t even able to do that…

Any help would be hugely appreciated.
Thanks a lot!

davidaviola

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJul 10.2006 — Take a look at this page:

http://msdn.microsoft.com/workshop/author/dynstyle/styles.asp

It might give you some ideas.
×

Success!

Help @davidaviola spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...