Jump to content

conditional CSS in header


jigarshah

Recommended Posts

Guest orang flores
I want to include <link href="http://www.myplace.com/my_css.css" type="text/css" rel="stylesheet" /> in head section after some javascript validation how can i do that ?
I'm not sure what do you mean, but if you want to connect the external css file to your page it should looks like this <link rel="stylesheet" type="text/css" href="http://www.myplace.com/my_css.css"> it works on my page anyway.As long as javascript placed between<script type="text/javascript">and </script> the same goes with CSS placed between <style type="text/css"> and </style> it doesn't matter how you place them there, but making sure it is place them between <head> and </head>sorry if this isn't the right answer
Link to comment
Share on other sites

I want to include <link href="http://www.myplace.com/my_css.css" type="text/css" rel="stylesheet" /> in head section after some javascript validation how can i do that ?
:) <head><script> //put javascript here</script><link rel="stylesheet" type="text/css" href="http://www.myplace.com/my_css.css" /></head>
Link to comment
Share on other sites

I think he only wants the css to apply if some javascript validation holds true..?<script type="text/javascript">if (true) {document.write('<link rel="stylesheet" type="text/css" href="http://www.myplace.com/my_css.css" />');}</script>But if this is the case I'd rather include it with a serverside script, because that javascript thing won't validate, as the <link> element isn't allowed within <script> tags...

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
×
×
  • Create New...