2

This site demos Social Sharing code such as 'share to Facebook'. Here, clicking the links on the left opens the sharing in a modal window. Their code:

<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=https://simplesharebuttons.com" target="_blank">
    <img src="https://simplesharebuttons.com/images/somacro/facebook.png" alt="Facebook" />
</a> 

I want a similar effect and I have the following anchor but this opens in a new tab. I want it to open in a modal window:

<a href="http://www.facebook.com/sharer.php?u=http://www.idybrand.com/" title="Share on Facebook" target="_blank" >
    <img alt="Share on Facebook" width="40" height="40" src="img/social_media/facebook.svg">
</a>

How can I achieve this please? Possibly using Bootstrap?

Janak
  • 4,986
  • 4
  • 27
  • 45
Dave Chambers
  • 2,483
  • 2
  • 32
  • 55

2 Answers2

3

Replace your code with this::

<a href="http://www.facebook.com/sharer.php?u=http://www.idybrand.com/" title="Share on Facebook" target="popup" onclick="window.open('http://www.facebook.com/sharer.php?u=http://www.idybrand.com/','popup','width=600,height=600'); return false;">
<img alt="Share on Facebook" width="40" height="40" src="img/social_media/facebook.svg">
</a>

It will work..

Rana Ghosh
  • 4,514
  • 5
  • 23
  • 40
2

You can use this. I hope it helps.

<a onclick="window.open('https://www.facebook.com/','mywindow','width=640,height=360')" href="javascript:void(0)"><button>Click FB</button></a>
shahzeb akram
  • 906
  • 7
  • 24