2 Replies - 1037 Views - Last Post: 02 April 2012 - 03:01 PM

#1 drayarms   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 199
  • Joined: 18-May 11

Dynamically changing the page background

Posted 02 April 2012 - 11:07 AM

Hello, I thought this was a very simple problem. I'm trying to set the various pages of a site with individual background themes. I want the users to define pick their own them color or image which would be stored in a database, and then dynamically applied via Ajax during runtime. To test the concept, I started off with this simple script which should set the background color of every page to white, except for 3 pages which I expect to retain the default background theme as defined in my css file(Default is a color gradient). Unfortunately, these 3 pages also displayed a white bg, and not the default gradient theme. Any ideas why? Here is the code.



		<script type='text/javascript'> //Assign page background dynamically


			$(document).ready(function() {


				if((window.location.href !== 'http://example.com/signup.php')||(window.location.href !== 'http://example.com/register.php')||(window.location.href !== 'http://example.com/login.php')){


					$('body').css('background','#fff');

				}
			
  

			});			



		</script>




This post has been edited by Dormilich: 02 April 2012 - 12:26 PM
Reason for edit:: fixing domain name


Is This A Good Question/Topic? 0
  • +

Replies To: Dynamically changing the page background

#2 enjoibp3   User is offline

  • New D.I.C Head

Reputation: 14
  • View blog
  • Posts: 49
  • Joined: 02-March 11

Re: Dynamically changing the page background

Posted 02 April 2012 - 01:55 PM

What happens if they are the pages in the if statement? Is it set in the css?

Edit: And by that I mean do you have the body color set to a different color in css?

This post has been edited by enjoibp3: 02 April 2012 - 01:56 PM

Was This Post Helpful? 0
  • +
  • -

#3 drayarms   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 199
  • Joined: 18-May 11

Re: Dynamically changing the page background

Posted 02 April 2012 - 03:01 PM

@enjoibp3. Yes there is a default CSS color for the backgrond(actually a gradient) which is defined in the site's style sheet. I expect this default style to apply when one of the above 3 pages is being viewed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1