jwermont Posted April 12, 2006 Share Posted April 12, 2006 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 More sharing options...
scott100 Posted April 12, 2006 Share Posted April 12, 2006 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 More sharing options...
jwermont Posted April 12, 2006 Author Share Posted April 12, 2006 Thanks - I think the problem was caused by an error in my JS code, which caused the whole script to be thrown out. Fixed that, it works now.Joyce Link to comment Share on other sites More sharing options...
Kosher Kid Posted April 13, 2006 Share Posted April 13, 2006 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} <{POST_SNAPBACK}> 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now