#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Body background image change from navigation link


    Hi guys!

    I'm looking for help to make following action on my customers site:

    I have different background image on index page that other "content" pages.

    How do i code this that body image changes when customer moves (clicks navigation link) from index page to content pages ??

    // Mika
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,119
    Rep Power
    119
    Are you redirecting index page to the other "content" pages, from the navigation menu or are you using AJAX; to display content in the the index page (from the navigation menu)? The reason, I ask; is that the CSS DOM would have to be applied a different way, with each instance.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Body background image change from navigation link


    Originally Posted by web_loone08
    Are you redirecting index page to the other "content" pages, from the navigation menu or are you using AJAX; to display content in the the index page (from the navigation menu)? The reason, I ask; is that the CSS DOM would have to be applied a different way, with each instance.

    Hi web_loone08,

    i'm redirecting to the content pages from navigation menu.

    // Mika
  6. #4
  7. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,119
    Rep Power
    119
    You probably would need to create a switch() statement and have it's conditions based on the current page's document.location.href or window.location and change the CSS background image accordingly.

    If you do not know the methods, that I am referring to above; these links/demos below, should get you started:

    The JavaScript Switch() Statement

    The location() Object

    CSS & JavaScript DOM Example >> Background Image
    Code:
    document.getElementsByTagName("body")[0].style.backgroundImage = "index_photo.jpg";

IMN logo majestic logo threadwatch logo seochat tools logo