Help with changing text and background colors.

Discussion in 'JavaScript' started by nothing2add, Jul 16, 2007.

  1. #1
    Hello all,

    I am working on a website, and I want to allow the users to change the text color and background color to color they choose. I have 10 html pages, and I want the changing option to appear in all of them. I have created a code using css + JS which is working perefectly on the main page, however; I want to have this fuction displayed on the other html pages by calling it. The code I created is this:

    <link rel="stylesheet" media="all" type="text/css" href="./main.css"/>

    </head>
    <body>

    <form>

    <div align="right">
    <p>
    <font size="-1"><strong>Change Backgroung Colour&nbsp;&nbsp;</strong></font>
    <br>
    <select name="ccGround" size="1"
    onChange="(document.bgColor=ccGround.options[ccGround.selectedIndex].value)">
    <option value="ffffff">White</option>
    <option value="fffaf0">Floral White</option>
    <option value="ccffff">Blue</option>
    <option value="ccccff">Lavender</option>
    <option value="008080">Teal</option>
    <option value="ffcccc">Pink</option>
    <option value="ffcc99">Orange</option>
    <option value="cccc99">Olive Green</option>
    <option value="ccffcc">Mint Green</option>
    <option value="cccccc">Gray</option>

    </select>
    </p>
    </div>

    </form>


    <form>

    <div align="left">
    <p>
    <font size="-1"><strong>Change Backgroung Colour&nbsp;&nbsp;</strong></font>
    <br>
    <script type="text/javascript">
    //<![CDATA[

    function ChangeFontColor(color) {

    document.body.style.color=color;
    }

    //]]>
    </script>

    </head>
    <body>

    <div>
    <button onclick="ChangeFontColor('red')">red</button>
    <button onclick="ChangeFontColor('blue')">blue</button>
    <button onclick="ChangeFontColor('green')">green</button>
    <button onclick="ChangeFontColor('brown')">brown</button>
    <button onclick="ChangeFontColor('black')">black</button>
    </div>


    </p>
    </div>

    </form>
    ===============================

    Anyone can help please?


    THanks in advance,
     
    nothing2add, Jul 16, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Do you mean that you want the browser to remember the color setting when the visitor goes to another page of your site?
     
    nabil_kadimi, Jul 16, 2007 IP
  3. nothing2add

    nothing2add Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello Nabil,

    What I want is that ( the user to be able to change the text color or background color in all the pages). In another word, I want to call the function into all of the other pages.

    I hope I have explained it 4 u.

    Thanks again,
     
    nothing2add, Jul 16, 2007 IP