/ Published in: JavaScript

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>
URL: http://javascript.internet.com/generators/popup-window.html
Comments
