4

I've got FB share working with the following code:

<a target="_blank" href="http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%3A%2F%2Fferalmotion.com%2Fshare%3Fwatch%3Dfd5f0c2"> 
<img src="/images/logo/facebook.png" alt="share on facebook"/> 
</a>

The problem is it opens in a full browser window. Does anybody know how I would get the share to open in the standard 500 x 360 pop-up window ???

TuK
  • 3,556
  • 4
  • 24
  • 24

2 Answers2

16

use

<a href="javascript:window.open('http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%3A%2F%2Fferalmotion.com%2Fshare%3Fwatch%3Dfd5f0c2', '_blank', 'width=400,height=500');void(0);">
<img src="/images/logo/facebook.png" alt="share on facebook"/>
</a>
Community
  • 1
  • 1
Riki137
  • 2,076
  • 2
  • 23
  • 26
7

javascript will do the job.

<script type="text/javascript">
<!--
function myPopup(url) {
window.open( url, "myWindow", "status = 1, height = 500, width = 360, resizable = 0" )
}
//-->
</script>

<a target="_blank" href="javascript:myPopup('http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%3A%2F%2Fferalmotion.com%2Fshare%3Fwatch%3Dfd5f0c2')"> 
<img src="/images/logo/facebook.png" alt="share on facebook"/> 
</a>
The Lazy Coder
  • 11,560
  • 4
  • 51
  • 69
  • 6
    A slightly better way to do this would be: You should never put JS in the HREF (separation of content/behaviour, etc). – BlueSix Nov 24 '14 at 01:31
  • works but the pop up opens in the top left corner. how do you move it to the center of the window? – valerio0999 Mar 03 '17 at 09:11