/    Sign up×
Community /Pin to ProfileBookmark

change the css file with javascript?

Hello all,

I am wondering if I would be able to change which css file the browser reads depending on the browser that is viewing the document.

For example, lets say someone is viewing the document with netscape. Since they are seeing the page with netscape, the javascript would run the file “netscape.css”. Further, if they are viewing the document with IE, the javascript would run the “ie.css” file.

Is this possible?

Thanks,

Brian

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJul 19.2003 — You coud do something like this:

[FONT=courier new]

if (navigator.appName=="Microsoft Internet Explorer") {

document.writeln('<link rel="stylesheet" type="text/css" href="ie.css" />');

}

else {

document.writeln('<link rel="stylesheet" type="text/css" href="netscape.css" />');

}

[/FONT]
×

Success!

Help @haynbrian 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,
)...