Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Frame background colour

    Hi all,

    Wanting to do the crazy thing again.....

    If I use the style="background-color: transparent" in the <body> tag of the html what will show through? Should it be the previous background colour of the frame? Should it be the previous contents of the frame? If neither, why would you want to specify it?

    The reason I ask is that I want to dynamically change the background color of the frame, but without changing the html for each page I want to display in the frame e.g., I choose green as my default background, and whether I look at page 1 or page 2 in my frame, I see the green background. Fred on the other hand chooses purple as his default background and sees purple whether looking at page 1 or page 2. Now, I can dynamically change the background within page 1 and also within page 2 which is fine albeit complicated, but not if you have a thousand pages to change! It would therefore be so much easier to set it to 'transparent' and have the default background showing through.

    Anybody any ideas as to how this might be accomplished? Please be gentle - I have grand ideas but little knowledge.....

    Regards

    David

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script type="text/javascript">
    function changeBg(){
    	if(parent.test.location=='http://www.yoursite.com/page1.html'){
    		parent.test.document['body'].style.background='#008000';
    	}
    	else if(parent.test.location=='http://www.yoursite.com/page2.html'){
    		parent.test.document['body'].style.background='#0000FF';
    	}
    	else if(parent.test.location=='http://www.yoursite.com/page3.html'){
    		parent.test.document['body'].style.background='#FF0000';
    	}
    	alert(parent.test.location);
    }
    </script>
    </head>
    
    <body>
    <iframe name="test" onload="changeBg()" id="test" src="page1.html"></iframe>
    </body>
    </html>
    Last edited by _Aerospace_Eng_; 11-30-2005 at 08:06 PM.


  •  

    Posting Permissions

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