Results 1 to 2 of 2

Thread: changing bg colour with javascript! help please?

  1. #1
    Join Date
    Mar 2012

    changing bg colour with javascript! help please?

    Hi all!

    I am trying to have an option on my webpage that I'm making which will allow users to change bg colour if they are unable to see clearly.

    I was experimenting with this code:
    <script language="JavaScript">
    function changeBGC(color){
    document.bgColor = color;
    <p><a><img src="../website - final/images/red.png" width="30" height="30"  href="#" onClick="javascript:changeBGC('#DC143C')" ></a>  
    <a><img src="../website - final/images/green.jpg" width="30" height="30"  href="#" onClick="javascript:changeBGC('#00CD00')" ></a>
    <a> <img src="../website - final/images/yellow.png" width="30" height="30"  href="#" onClick="javascript:changeBGC('#FFFF00')" ></a></p>
    This works fine and well but when I try it on my webpage, it doesn't.
    I'm confused to why its doing this... any help?

    my webpage is being made in dreamweaver:
      <div id="pagetitle"><img src="images/HISTORY.jpg" /></div>
      <div id="logolink"><a href="http://www.facebook.com/groups/3rdgalabb" target="_blank"><img src="images/Picture1.png" width="55" height="60" border="0" align="left" /></a></p>
      <a href="http://scotland.boys-brigade.org.uk/" target="_blank"><img src="images/small logo.png" width="70" height="70" border="0" align="left" /></a></div>
      <div id="information">
        <p>The Boys&rsquo;  Brigade was founded in Glasgow, Scotland on 4th October 1883 by  William Alexander Smith who was a businessman part time soldier and a devoted  Christian. </p>
        <p>William Smith was 29 years old when he had founded the first ever Boys Brigade. Mr Smith had the idea of turning Sabbath school boys into a volunteer brigade but with the same military order, obedience discipline and importantly self respect. Combining all this with religious services with games and enjoyment became the core of the Boys’ Brigade. </p>
    <p><img src="images/williamsmith.jpg" width="197" height="226" hspace="10" align="right" />On October 1883, the leaders invited the boys of the North Woodside Mission Sabbath School to the join the Boys’ Brigade. The anchor badge that we know of now was created then and the motto, “Sure and Steadfast” was from Hebrews, chapter 6, verse 19. .</p>
    <p>  By this  time, William Smith had given up all his jobs to work fulltime for the Boys&rsquo;  Brigade. </p>
        <p>  In July  1909, William Alexander Smith had been knighted by King Edward VII for outstanding services to boys. 5 years later, he had died.</p>
        <p>  Although Sir  William Smith could not see the improvement for himself, he would have been  proud of the work that had been started. In early 20th Century there  were well over 2,000 companies connected with different churches throughout the  United Kingdom, British Empire and the United States.</p>
        <p><img src="images/oribblogo.jpg" width="144" height="148" hspace="10" align="left" />Each company  is normally affiliated to a battalion which are organized at a district and  then to national level. However, here in Scotland, each company (such as  ourselves) are attached to a local district – which is attached to a battalion. </p>
        <h3>Key  Dates</h3>
        <p><img src="images/boys_brigade_poster.jpg" alt="" width="200" height="300" border="2" align="right" />1854 - William Alexander Smith born (27th October)<br />
          1883 - BB Founded in Glasgow (4th October)<br />
          1886 - First BB Camp (Tignabruaich)<br />
          1908 - Scout Movement Formed (by Baden Powell, developed from the BB)<br />
          1909 - William Alexander Smith knighted (July)<br />
          1914 - Sir William Alexander Smith died (10th May)<br />
          1917 - Boy Reserves started<br />
          1926 - Amalgamation of The Boys' Brigade with The Boys' Life Brigade<br />
          1933 - Jubilee Celebrations<br />
          1976 - World Conference (of The Boys' Brigade) formed<br />
          1983 - Centenary Celebrations<br />
          1993 - Junior Section 75th Anniversary (previously called 'Life Boys')<br />
          2002 - World Conference renamed to Global Fellowship of Christian Youth<br />
          2004 - 150th Anniversary of the Founder's birth<br />
          2008 - 125th Anniversary of The Boys' Brigade<br />
        2011 - 125th Anniversary of Camping in The Boys' Brigade</p>
        <script type="text/javascript">
    function resizeText(multiplier) {
    var thediv=document.getElementById("information")
      if (thediv.style.fontSize == "") {
        thediv.style.fontSize = "1.0em";
      thediv.style.fontSize = parseFloat(thediv.style.fontSize) + (multiplier * 0.2) + "em";
      <div id="bbnotes"></div>
    <div id="footer">
      <p>Scottish Charity number: 09382032039</p>
      <div id="resize">Change text size:<br><a name="change">
    <img src="images/subtract.png" alt="Decrease text size" width="30" height="30" hspace="2" id="minustext" onclick="resizeText(-1)" />
    <img src="images/add.png" alt="Increase text size" width="30" height="30" id="plustext" onclick="resizeText(1)" /></a></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    Where would I have to put my code in order for it to work?

    Thanks in advance!
    Last edited by jamesy23; 05-26-2012 at 01:21 PM.

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    function changeBGC(color){
    document.body.backgroundColor = color;
    signature under construction

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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