Javascript to open link in new popup window

html, javascript

Solution

Here is your working code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
  <li>
    <a href="//somesite.com/" rel="nofollow" class="social_share_link">Share</a>
  </li>
</ul>

these are the changes you will need to do:

$("a.social_share_link").on("click", function() {
  var share_link = $(this).prop('href');
  console.log(share_link);
window.open(share_link, "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");

});

you can also refer the Working Fiddle here https://jsfiddle.net/9wua66mw/

Problem

I am working on a theme in wordpress and creating inline sharing buttons at the bottom of posts but I am stuck at a point. I want to open link in new popup window using javascript. Here is the html code. ``` <ul> <li> <a href="//somesite.com/" rel="nofollow" class="social_share_link">Share</a> </li> </ul> ``` and here is the javascript ``` <script type="text/javascript"> $("a.social_share_link").on("click",function(){ var share_link = $(this).prop('href'); window.open(share_link,'','scrollbars=1,height=500,width=500,left=500,top=100'); }); </script> ``` Please help me.

Original source