Problem dynamically loading style sheet

Discussion in 'Javascript' started by Hank Flowers, Apr 10, 2004.

  1. Hank Flowers

    Hank Flowers Guest

    In trying to load a style sheet via JavaScript I ran into a problem...the
    style sheet doesn't load. This simple task has turned into a vexing problem.
    Here is the script and html:

    <html>
    <head>
    <title>load a style sheet</title>
    <script type="text/javascript" language="JavaScript">
    var mystyle="css/mystyle.css";
    document.write=("<link rel='stylesheet' href='" + mystyle + "'
    type='text/css'>");
    </script>
    </head>
    <body>
    <p class="foobar">display some text in the foobar class</p>
    </body>
    </html>

    This is so simple it almost has to work, but it doesn't. I'm suspecting
    either the browser is the problem (IE5.5) or maybe it has something to do
    with being a local file or both or none of the above...dunno. Can anybody
    see anything wrong here?

    TIA!
    Hank Flowers, Apr 10, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Roberts
    Replies:
    2
    Views:
    10,855
    Rob Roberts
    Jan 21, 2006
  2. AC

    Style sheet problem

    AC, Apr 5, 2004, in forum: HTML
    Replies:
    8
    Views:
    393
    Toby A Inkster
    Apr 5, 2004
  3. enerion
    Replies:
    0
    Views:
    538
    enerion
    Apr 13, 2004
  4. Replies:
    0
    Views:
    516
  5. Ken Varn
    Replies:
    0
    Views:
    446
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page