Reputation: 7601
I'm using the following code to generate a Facebook share button:
<li>
<a
href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fsimplesharingbuttons.com%2F&t="
target="_blank"
title="Share on Facebook"
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(document.URL) + '&t=' + encodeURIComponent(document.URL)); return false;">
<i class="fa fa-facebook-square fa-2x"></i>
</a>
</li>
As you can see, I'm using window.open
, but the share dialogs opens in a new browser tab instead of a popup window.
How to modify this code to open the dialog in a popup window?
Codepen: http://codepen.io/alexcheninfo/pen/OXpRjd
Upvotes: 0
Views: 244
Reputation: 11
Please try with this:
window.open("http://www.w3schools.com", '_blank', 'left=20,top=20,width=950,height=650');
The second parameter is '_blank' The third parameter is some specifications that are separated by comma: height, width,....
Upvotes: 0
Reputation: 404
You have to provide extra specification to your window.open() ;
window.open('yourlink','windownam' , 'width=400,height=200,scrollbars=yes');
Upvotes: 1
Reputation: 1041
Basically, this is controlled by the browser and the browsers options, no good way to force this behavior (window vs tab).
See similar answer here JavaScript open in a new window, not tab which indicates there is a method (height/width) that works (as a hack) on some browsers.
Upvotes: 0