SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using javascript to declare CSS

    increasingly, I've seen professional websites utilize javascript to declare CSS styles. Sites like:

    www.blastradius.com
    www.olympic.org

    in their code, they have something like this:

    Code:
    <link rel="stylesheet" type="text/css" href="css/global.css" />	
    <script language="javascript" type="text/javascript" src="js/css_adjustment.js"></script>
    <script language="javascript" type="text/javascript" src="js/rollover.js"></script>
    <script language="javascript" type="text/javascript" src="js/netcssfix.js"></script>
    <script language="javascript" type="text/javascript" src="js/window.js"></script>
    Code:
    		<script language="JavaScript" src="/common/scripts/style_games.js"></script>
    		<script language="JavaScript" src="/common/scripts/open.js"></script>
    I am curious as to why Javascript is used to define CSS this way if we can't totally assume that everyone has JavaScript enabled on their computer. Could anyone shed some light into this?

    Thanks.
    signature

  2. #2
    SitePoint Addict
    Join Date
    Jul 2001
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like they are calling external javascript pages. The first line is the normal css call, but the rest are javascripts being used such as for the rollovers and such.

    The css adjustment script is to apply a different css setting depending on the browser type being used... but it is still an external javascript.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •