Last active
June 14, 2017 15:44
-
-
Save ebinnion/5095189 to your computer and use it in GitHub Desktop.
Facebook centered pop up share
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function fbs_click(width, height) { | |
var leftPosition, topPosition; | |
//Allow for borders. | |
leftPosition = (window.screen.width / 2) - ((width / 2) + 10); | |
//Allow for title and status bars. | |
topPosition = (window.screen.height / 2) - ((height / 2) + 50); | |
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"; | |
u=location.href; | |
t=document.title; | |
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures); | |
return false; | |
} | |
</script> | |
<!-- Please change the width and height to suit your needs --> | |
<a href="http://www.facebook.com/share.php?u=<full page url to share" onClick="return fbs_click(400, 300)" target="_blank" title="Share This on Facebook"><img src="images/facebookimage.jpg" alt="facebook share"></a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Twitter and Facebook Popup Windows | |
//twitter, facebook, javascript | |
//I often find my self needing to add Twitter and Facebook share buttons. Usually not using the default widget icons. To do that // you need some functions to call window.open and some jQuery to tie the links to those functions. These functions also encode // the passed parameters. | |
var tweetWindow = function(url, text) { | |
window.open( "http://twitter.com/share?url=" + | |
encodeURIComponent(url) + "&text=" + | |
encodeURIComponent(text) + "&count=none/", | |
"tweet", "height=300,width=550,resizable=1" ) | |
} | |
var faceWindow = function(url, title) { | |
window.open( "http://www.facebook.com/sharer.php?u=" + | |
encodeURIComponent(url) + "&t=" + | |
encodeURIComponent(title), | |
"facebook", "height=300,width=550,resizable=1" ) | |
} | |
jQuery to enhance the link. This may or may not be used with the above. | |
$(".twitter").click(function(e) { | |
e.preventDefault(); | |
var href = $(e.target).attr('href'); | |
window.open(href, "tweet", "height=300,width=550,resizable=1") | |
}); | |
//The link; using target _blank to work without JavaScript | |
<a href="https://twitter.com/share?text=SOME%20TEXT&via=candland" | |
class="twitter" | |
target="_blank">Twitter Link%lt;/a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment