55 users online (1 members and 54 guests)  


  Results 1 to 7 of 7

Related

  1. Replies: 1
  2. Replies: 0
  3. Multiple CSS Classes on 1 Page?    Forum: CSS Forum
    Replies: 2
  4. Replies: 15
  5. multiple submit buttons in single form    Forum: HTML Forum
    Replies: 7
  1. #1
    berklee555's Avatar
    New User

    Status
    Offline
    Join Date
    May 2004
    Posts
    3

    Single Page, Multiple Backgrounds?

    Well this one has me stumped. I've been searching up and down on the web for the entire day and this looks to be the best place to ask my question.

    I have a site for a gaming clan that I formed a while ago. Now for the website I have a few pages that are common to the two divisions in the clan. But, on the site itself I have a color/image theme for one division, and another color/image theme the other division. With that, there are two sets of frames, one for division a, and one for division b, each with their respective names... my problem is this...

    I want to have the background for the content frame of these framesets to change depending on which division the users are browsing in. So for instance, in Division A, the background image will be red, and Division B, the background image will be grey. Basically the script needs to detect the name of the content frame for that specific division, and then change the background of the content page it links to accordingly. Hers's what I have so far...

    Code:
    <script language="JavaScript1.4" type="text/javascript">
                                    if (parent.frames["mainFrame"])
    		{
    		document.body.bgImage = "background.bmp";
    		}
    		if (parent.frames["content"])
    		{
    		document.body.bgImage = "texture.jpg";
    		}		
    </script>
    It keeps returning 'Object required'. I've tried a million different ways of choosing the body element, like with the getElementById() method, and still it's giving me issues.

    Any help?
    Last edited by berklee555; 05-06-2004 at 02:53 PM.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Thats a great question.

    Have you considered changing the class of the page via JavaScript?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    berklee555's Avatar
    New User

    Status
    Offline
    Join Date
    May 2004
    Posts
    3
    Well, i tried what they described, and still no luck. Now I'm getting 'identity is null or not an object'

    This one has me completely stumped.

    Here is the style and script i have in the page currently:

    Code:
                         
    <style type="text/css">
    csbg { background-image: url("../../universal/background.bmp") }
    tfcbg { background-image: url("../../universal/texture.jpg") }
    </style>
    <script language="JavaScript" type="text/javascript">
    function change(id, newClass) 
    {
    document.getElementById(id).className=newClass;
    }
    if (parent.frames["mainFrame"])
    {
    change('rules', 'csbg')
    }
    if (parent.frames["content"])
    {
    change('rules', 'tfcbg')
    }	
    </script>
    Also, the body of the page has an onLoad of onLoad="change('rules', 'csbg')"

    I'm sure it's something completely boneheaded that I'm missing...
    Last edited by berklee555; 05-06-2004 at 07:42 PM.

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Have you added an ID to the body tag?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    berklee555's Avatar
    New User

    Status
    Offline
    Join Date
    May 2004
    Posts
    3
    Yeah, i tried that. It didn't work...mostly because the getElementByID() method was giving me all kinds of problems saying that it was null or not an object of the document element. I finally did get it working, here's the script as it stands now....

    Code:
    <script language="JavaScript1.2" type="text/javascript">
    <!--
    var bg = new Array();
    bg[0] = 'http://www.clan46and2.com/universal/background.bmp'
    bg[1] = 'http://www.clan46and2.com/universal/texture.jpg'
    var p = bg.length
    var preLoad = new Array()
    for (i = 0; i < p; i++){
    preLoad[i] = new Image()
    preLoad[i].src = bg[i]
    function texture()
    {
    if (parent.frames["mainFrame"])
    {
    document.body.background = bg[0];
    }
    else
    {
    document.body.background = bg[1];
    }
    }
    }		  
    // -->
    </script>

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Great, as long as its working. Thanks for letting us know the solution.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    jgheyen's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2004
    Posts
    1

    Code for homepage with multiple backgrounds possible

    Looking for code which will display a different background (from a list) on a home page each time user displays home page.

    Thanks



Tags for this Thread