Title: Java specific for homepage
Last modified: December 15, 2017

---

# Java specific for homepage

 *  Resolved [tistrega](https://wordpress.org/support/users/tistrega/)
 * (@tistrega)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/java-specific-for-homepage/)
 * Hello!
 * Thanks for the plugin, for the rich documentation and for the
    fast and great
   support!
 * I have an homepage full width and the floating buttons go over the text in some
   sections.
    I apply the code that you have recommended to [@jamesyesjames](https://wordpress.org/support/users/jamesyesjames/)
   and [@fjura](https://wordpress.org/support/users/fjura/) and it work perfectly
   for me too!
 * Particularly, I insert this to adapt show and fadeout to my homepage:
 *     ```
       jQuery(window).scroll(function () {	 
           var y = jQuery(this).scrollTop();
       	var url= window.location.href;
   
       	if(y < 1200 || y > 2900) {
               jQuery('.a2a_floating_style.a2a_vertical_style').fadeOut();
           } 
       	else {
               jQuery('.a2a_floating_style.a2a_vertical_style').show();
           }
       });
       ```
   
 * However, in this way, the rule is applied to all other pages and post where I
   have page
    shorter and I set primary content with specific padding left for buttons.
 * There is a way to apply this rule only on homepage (or other specific page)?
 * I tried a lot of solutions, but none works for me.
 * For example, adding an else if
    `else if(window.location.pathname == ‘/contatti’){
   jQuery(‘.a2a_floating_style.a2a_vertical_style’).show(); } ` ok in homepage, 
   but it does not work on the specific page (perhaps because I need specific var?),
 * or using `( is_page('contatti') )`, or `( is_home() )`, but sometimes this also
   creates conflicts with background images and the button disappear on home.
 * I’m sorry…I do not know java
 * Thanks in advance
 * Ro’
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjava-specific-for-homepage%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [micropat](https://wordpress.org/support/users/micropat/)
 * (@micropat)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/java-specific-for-homepage/#post-9787336)
 * Pretty close! It’s best to wrap the whole JavaScript code block in a conditional
   statement:
 *     ```
       var myCurrentPath = window.location.pathname;
       // If homepage, or another specific page
       if (myCurrentPath === '/' || myCurrentPath === '/another-specific-page/') {
           jQuery(window).scroll(function () {	 
               var y = jQuery(this).scrollTop();
               var url= window.location.href;
   
               if(y < 1200 || y > 2900) {
                   jQuery('.a2a_floating_style.a2a_vertical_style').fadeOut();
               } 
               else {
                   jQuery('.a2a_floating_style.a2a_vertical_style').show();
               }
           });
       }
       ```
   
 * And to prevent the initial display & fade-out when the page loads, add some “
   Additional CSS” code that applies to your homepage:
 * `body.home .a2a_floating_style.a2a_vertical_style { display: none; }`
 *  Thread Starter [tistrega](https://wordpress.org/support/users/tistrega/)
 * (@tistrega)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/java-specific-for-homepage/#post-9787642)
 * Great! Works perfectly!!!
    Thank you so much for the quick help!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Java specific for homepage’ is closed to new replies.

 * ![](https://ps.w.org/add-to-any/assets/icon.svg?rev=972738)
 * [AddToAny Share Buttons](https://wordpress.org/plugins/add-to-any/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/add-to-any/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/add-to-any/)
 * [Active Topics](https://wordpress.org/support/plugin/add-to-any/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/add-to-any/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/add-to-any/reviews/)

## Tags

 * [addtoany](https://wordpress.org/support/topic-tag/addtoany/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 2 replies
 * 2 participants
 * Last reply from: [tistrega](https://wordpress.org/support/users/tistrega/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/java-specific-for-homepage/#post-9787642)
 * Status: resolved