Return to Snippet

Revision: 43545
at March 26, 2011 03:21 by nielsenrc


Updated Code
<script type="text/javascript">
 function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 710,top = 290');");
}
</script>

<?php
$currentsite = "Enter your URL Here";
$twitter_url = "http://twitter.com/share?url=" . $currentsite . "&text=I found this great site at " . $currentsite;
$facebook_url = "http://www.facebook.com/sharer.php?u=" . $currentsite;
?>

<a href="javascript:popUp('<?php print urlencode($facebook_url); ?>')"><img src="images/facebook.gif" alt="facebook"/></a>
<a href="javascript:popUp('<?php print urlencode($twitter_url); ?>')"><img src="images/twitter.gif" alt="twitter"/></a>

Revision: 43544
at March 26, 2011 01:42 by nielsenrc


Initial Code
<script type="text/javascript">
 function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 710,top = 290');");
}
</script>

<a href="javascript:popUp('http://www.facebook.com/sharer.php?u=<?php print $currentsite; ?>')"><img src="images/facebook.gif" alt="facebook"/></a>

<a href="javascript:popUp('http://twitter.com/share?url=<?php print $currentsite;?>&text=I found this exciting offer at <?php print $currentsite; ?>')">  <img src="images/twitter.gif" alt="twitter"/></a>

Initial URL
http://javascript.internet.com/generators/popup-window.html

Initial Description
This code actually opens up another tab (rather than a pop up) in IE6 & IE7  - but if you can live with that it seems to work well in all modern browsers. I'm open to any additions/revisions that anyone finds appropriate. Props to the URL above for providing the pop up function. I use PHP in this case to supply the URL to be shared - feel free to replace with a static url or whatever you need.

Initial Title
Custom Facebook Share and Twitter Tweet Buttons

Initial Tags


Initial Language
JavaScript