swop between css files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    #1

    swop between css files?

    Hello

    Is it possible to use javascript to swop between css files?

    Cheers

    Geoff
  • Vladdy

    #2
    Re: swop between css files?

    Geoff Cox wrote:
    [color=blue]
    > Hello
    >
    > Is it possible to use javascript to swop between css files?
    >
    > Cheers
    >
    > Geoff[/color]

    Only in latest browsers. I was able to get it working in Gecko and IE6.0

    For an example of client-side stylesheet switcher, see my customization
    gadget at http://www.klproductions.com

    Vladdy.

    Comment

    • HikksNotAtHome

      #3
      Re: swop between css files?

      In article <m91kuv0337qhk4 m585n8tkcp2q6lg 3gb5d@4ax.com>, Geoff Cox
      <geoffacox@dont spamblueyonder. co.uk> writes:
      [color=blue]
      >Is it possible to use javascript to swop between css files?[/color]

      <link rel="stylesheet " type="text/css" href="testFile1 .css" id="linkTag">

      Add an id attribute to your link tag and then change its .href property..

      function changeCSSFile(n ewFile){
      document.getEle mentById('linkT ag').href = newFile;
      }

      Works in IE6.0, Firebird 1.4 and Opera 7.

      Test page at <URL:
      http://members.aol.com/_ht_a/hikksno...ile/index.html />
      --
      Randy

      Comment

      • JimMenees

        #4
        Re: swop between css files?

        I found that by referencing the style sheet via a <link tag:
        <link id="css_ref" type="text/css" href="styleshee t1.css" />

        you can change its file reference using:
        document.getEle mentById('css_r ef').href="new_ stylesheet.css"

        This seems to work in MSIE 6 and NN7;

        If you don't want to change an entire stylesheet, just the class, you can give
        your element an id and change the class thusly:
        <div id="redtext"
        onMouseover="do cument.getEleme ntById(this.id) .className='new classname' " >

        The class name changer appears to work for MSIE6 and NN7.

        Hope this helps,

        Jim

        Comment

        • HikksNotAtHome

          #5
          Re: swop between css files?

          In article <20031224181850 .15599.00001702 @mb-m03.aol.com>,
          jimmenees@aol.c omNoSpam (JimMenees) writes:
          [color=blue]
          >If you don't want to change an entire stylesheet, just the class, you can
          >give
          >your element an id and change the class thusly:
          ><div id="redtext"
          >onMouseover="d ocument.getElem entById(this.id ).className='ne wclassname' " >
          >
          >The class name changer appears to work for MSIE6 and NN7.[/color]

          That can be simplified to:

          <div id="redtext" onMouseover="th is.className='n ewclassname' " >

          --
          Randy

          Comment

          • Geoff Cox

            #6
            Re: swop between css files?

            On 25 Dec 2003 00:24:48 GMT, hikksnotathome@ aol.com (HikksNotAtHome )
            wrote:
            [color=blue]
            >In article <20031224181850 .15599.00001702 @mb-m03.aol.com>,
            >jimmenees@aol. comNoSpam (JimMenees) writes:
            >[color=green]
            >>If you don't want to change an entire stylesheet, just the class, you can
            >>give
            >>your element an id and change the class thusly:
            >><div id="redtext"
            >>onMouseover=" document.getEle mentById(this.i d).className='n ewclassname' " >
            >>
            >>The class name changer appears to work for MSIE6 and NN7.[/color]
            >
            >That can be simplified to:
            >
            ><div id="redtext" onMouseover="th is.className='n ewclassname' " >[/color]

            Thanks everyone - will have a try!

            Cheers

            Geoff

            Comment

            Working...