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 Coder
    Join Date
    Jul 2011
    Posts
    54
    Thanks
    5
    Thanked 1 Time in 1 Post

    Floating Menu Javascript Issues

    Hello Everyone,

    I am trying to add a floating share bar on my wordpress website.

    I got one script from here: Floating Menu Script

    This is working fine in my thesis theme but there is few errors which are listed following:

    1- If I installed any comments plugin it stop working
    2- The hover apply to all my social icons which is in sidebar example (Twitter Follow Button, Facebook Page Like Button and Google plus buttons)

    I think that all the issue is in this code

    Code:
    $(document).ready(function () {
    var top = $('#floating-sharebar').offset().top;
    $(window).scroll(function (event) {
    var y = $(this).scrollTop();
    var maxY = $('#respond').offset().top;
    if (y >= top && y < maxY) {
    $('#floating-sharebar').addClass('fixed');
    } else {
    $('#floating-sharebar').removeClass('fixed');
    }
    });
    });
    Code:
    /** Script for Google +1 Button */
    $(document).ready(function () {
    var element, script;
    element = document.getElementById('floating-gplus');
    element.onmouseover = function () {
    this.onmouseover = null;
    this.parentNode.removeChild(this);
    script = document.createElement('script');
    script.async = true;
    script.src = '//apis.google.com/js/plusone.js';
    document.body.appendChild(script);
    };
    });
    /** Script for Facebook Like Button */
    $(document).ready(function () {
    var element, script;
    element = document.getElementById('floating-facebook');
    element.onmouseover = function () {
    this.onmouseover = null;
    this.parentNode.removeChild(this);
    script = document.createElement('script');
    script.async = true;
    script.src = '//connect.facebook.net/en_US/all.js#xfbml=1';
    document.body.appendChild(script);
    };
    });
    /** Script for Tweet Button */
    $(document).ready(function () {
    var element, script;
    element = document.getElementById('floating-twitter');
    element.onmouseover = function () {
    this.onmouseover = null;
    this.parentNode.removeChild(this);
    script = document.createElement('script');
    script.async = true;
    script.src = '//platform.twitter.com/widgets.js';
    document.body.appendChild(script);
    };
    });
    /** Script for Stumble Upon Button */
    $(document).ready(function () {
    var element, script;
    element = document.getElementById('floating-stumble');
    element.onmouseover = function () {
    this.onmouseover = null;
    this.parentNode.removeChild(this);
    var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
    li.src = 'https://platform.stumbleupon.com/1/widgets.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
    script = document.createElement('script');
    script.async = true;
    script.src = '//platform.stumbleupon.com/1/widgets.js';
    document.body.appendChild(script);
    };
    });
    Thank You

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,686
    Thanks
    25
    Thanked 656 Times in 655 Posts
    You should only have one
    Code:
    $(document).ready(function () {
    for your code. I stopped counting how many you have at 3.


  •  

    Posting Permissions

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