Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:45:10+00:00 2026-05-30T20:45:10+00:00

I’m trying to make it so that when you click the navigation buttons at

  • 0

I’m trying to make it so that when you click the navigation buttons at the top of my page, they cause the background to change. I was partially successful but the background always switches back immediately and I would like each background to fade into the next one.
Here’s the javascript on the first page with the html:

<script type="text/javascript">
$('li a').click(function(e){
     e.preventDefault();
     $.cookie('currentImg', $('body').css('background-image') );
     $.cookie('nextImg', 'Tranquil.jpg');
});
</script>

<li class="item6" onmouseover="style.backgroundColor='#022D4D';" onmouseout="style.backgroundColor='#032F76';"><a href="Environment.php" onClick="EnvBack();" title="Environment" >Environment</a></li>

Here’s the javascript on the new page:

<script type="text/javascript">
//on next page (Environment.php)

//#nextImage is a div covering the page with a z-index placing just above the body element
$('body').css('background-image', $.cookie('currentImg') );
$('#nextImage').css({
      visibility : 'hidden',
      backgroundImage : $.cookie('nextImg')
  //wait for image to load
}).load(function(){
     //set state to hidden, if it was hidden before rather than merely 
     //invisible the div will not load.
     //then fade in the new image producing a smooth transition
     $(this).css('visibility','visible').fadeIn(function(){
           //reset state of page
           $('body').css('background-image', $.cookie('nextImg') );
           $(this).remove();
     });
});
</script>

Here’s the CSS for the body:

body
{
    background-image:url("abstract1.jpg");
    background-repeat: no-repeat;
    background-size:100%;
    background-attachment:fixed;
    font-family:font-family: Helvetica,Arial, sans-serif;
    text-align:center;
    width: 100%;
    height: 100%;
}
#nextImage
{
    background-image="";
    background-repeat: no-repeat;
    background-size:100%;
    background-attachment:fixed;
    font-family:font-family: Helvetica,Arial, sans-serif;
    text-align:center;
    width: 100%;
    height: 100%;
    z-index:1;
}

When I jump to new page.. all the css is invisible instead of it transitioning

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:45:12+00:00Added an answer on May 30, 2026 at 8:45 pm

    Much respect to VAShhh for catching refresh part of this equation.

    First you need to transfer the current image setting to the new page via a cookie, the image can remain after refresh. In this example I am going to transfer both the current and the desired image. (jquery cookie plugin required)

    //its important to use jQuery here so we have a normalized event object
    $('li a').click(function(e){
         e.preventDefault();
         $.cookie('currentImg', $('body').css('background-image') );
         $.cookie('nextImg', 'Tranquil.jpg');
    });
    
    //on next page (Environment.php)
    
    //#nextImage is a div covering the page with a z-index placing just above the body element
    $('body').css('background-image', $.cookie('currentImg') );
    $('#nextImage').css({
          visibility : 'hidden',
          backgroundImage : $.cookie('nextImg')
      //wait for image to load
    }).load(function(){
         //set state to hidden, if it was hidden before rather than merely 
         //invisible the div will not load.
         //then fade in the new image producing a smooth transition
         $(this).hide().css('visibility','visible').fadeIn(function(){
               //reset state of page
               $('body').css('background-image', $.cookie('nextImg') );
               $(this).remove();
         });
    });
    

    You cannot cross-fade between css background images on the same element. To achieve the effect you are looking for you will need a minium of two elements. One to hold the initial image, and the other to hold the new one. Place the new one over the old one (z-index) and fade the element with the new image in.

    You might want to check out a jQuery plugin for this like:
    http://tympanus.net/Tutorials/CSS3FullscreenSlideshow/index.html
    http://buildinternet.com/project/supersized/
    http://tobia.github.com/CrossSlide/

    Keep in mind you will also have to preload the next image in line BEFORE fading otherwise it will look shitty.

    Here is an example of one that I wrote myself:

    http://www.wideopenadventure.com/woa/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.