...

View Full Version : Floating Menu Javascript Issues



unleash
11-02-2012, 07:00 PM
Hello Everyone,

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

I got one script from here: Floating Menu Script (http://www.wpsquare.com/add-floating-lazy-load-social-share-buttons-wordpress/)

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 ho:over 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



$(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');
}
});
});



/** 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

sunfighter
11-03-2012, 02:47 PM
You should only have one
$(document).ready(function () {
for your code. I stopped counting how many you have at 3.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum