Jump to content

Using appropriate CSS file for browser


jwermont
 Share

Recommended Posts

Hello,I have the following code inside the <head> section of my HTML file. The style definitions in these CSS files are not being recognized. Does anyone know what's wrong?

<script language="Javascript" type="text/javascript">switch (navigator.appName) {   case "Netscape":     document.write('<link rel="stylesheet" href="stylemoz.css" type="text/css" media="all">')      break   case "Microsoft Internet Explorer":      document.write('<link rel="stylesheet" href="styleie.css" type="text/css" media="all">')      break   default:      break}</script>

Thank you,Joyce

Link to comment
Share on other sites

It worked ok for me, i added text in the body and it changes colour. language isn't needed for script tag either

<head><script type="text/javascript">switch (navigator.appName){  case "Netscape":     document.write('<link rel="stylesheet" href="stylemoz.css" type="text/css" media="all">')     break  case "Microsoft Internet Explorer":        document.write('<link rel="stylesheet" href="styleie.css" type="text/css" media="all">')     break  default:     break}</script></head><body><p>Some Text</p></body>

I put this into the external syle sheets.styleie.css

body{color:red}

stylemoz.css

body{color:green}

Link to comment
Share on other sites

It worked ok for me, i added text in the body and it changes colour. language isn't needed for script tag either
<head><script type="text/javascript">switch (navigator.appName){  case "Netscape":     document.write('<link rel="stylesheet" href="stylemoz.css" type="text/css" media="all">')     break  case "Microsoft Internet Explorer":        document.write('<link rel="stylesheet" href="styleie.css" type="text/css" media="all">')     break  default:     break}</script></head><body><p>Some Text</p></body>

I put this into the external syle sheets.styleie.css

body{color:red}

stylemoz.css

body{color:green}

I have a different problem...I want to dynamically assign the link tag using a variable to specify the location of the style sheet. This is a reference to my post of 4-12.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...