Problem dynamically loading style sheet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hank Flowers

    Problem dynamically loading style sheet

    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="JavaS cript">
    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!


  • Dennis M. Marks

    #2
    Re: Problem dynamically loading style sheet

    In article <a0Ydc.12181$95 1.7288@bignews3 .bellsouth.net> , Hank Flowers
    <nospam@nospam. ca> wrote:
    [color=blue]
    > 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="JavaS cript">
    > 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!
    >
    >[/color]
    It's not document.write= (xxx
    It's document.write( xxx
    Leave out the equal sign.

    --
    Dennis M. Marks

    Replace domain.invalid with dcsi.net


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    Working...