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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

different css files depending on the operating system 1

Status
Not open for further replies.

Extras

Technical User
Nov 16, 2001
232
US
I would like to direct the browser to different css files (Winstyle.css, MacStyle.css) depending on their operating system.

Does anybody have some simple, straightforward code that I can adapt for this need?

Thanks!

 
Just add
document.write("/*what you would use to include the file*/");
to the ifs below:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function checkOS() {
if(navigator.userAgent.indexOf('IRIX') != -1){}
else if((navigator.userAgent.indexOf('Win') != -1) &&
(navigator.userAgent.indexOf('95') != -1)){}
else if(navigator.userAgent.indexOf('Win') != -1){}
else if(navigator.userAgent.indexOf('Mac') != -1){}
else {}
return OpSys;
}
// -->
</SCRIPT>

Rick
 
Am sorry, but I am total novice when it comes to javascript (as you can guess by my attempt below)..would this be something that you are mentioning...?

What doest the term IRIX refer to?


<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function checkOS() {
if(navigator.userAgent.indexOf('IRIX') != -1){<link href=&quot;includes/Macstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>}
else if((navigator.userAgent.indexOf('Win') != -1) &&
(navigator.userAgent.indexOf('95') != -1)){){<link href=&quot;includes/Winstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>}
else if(navigator.userAgent.indexOf('Win') != -1){){<link href=&quot;includes/Winstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>}
else if(navigator.userAgent.indexOf('Mac') != -1){){<link href=&quot;includes/Macstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>}
else {}
return OpSys;
}
// -->
</SCRIPT>
 
This should work. Just stick it in between <head> & </head> in your HTML:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
if(navigator.userAgent.indexOf('IRIX') != -1){
document.write('<link href=&quot;includes/Macstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>');
}
else if(navigator.userAgent.indexOf('Win') != -1){
document.write('<link href=&quot;includes/Winstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>');
}
else if(navigator.userAgent.indexOf('Mac') != -1){
document.write('<link href=&quot;includes/Macstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>');
}
else{
document.write('<link href=&quot;includes/Winstyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>');
}
// -->
</SCRIPT>

Rick
 
Thanks - I will give it a shot once I get the Mac version of my CSS ready to go!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top