最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ShareThis Button to Open in Popup - Stack Overflow

programmeradmin2浏览0评论

I am using Sharethis button for social media sharing. The problem is that when you click on Twitter, Facebook, Linkedin or any other button, it open in new tab. I want it to open in popup window. Is that possible to do. Here is the code I am using.

This goes in head section

    <script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src=".js"></script>
<script type="text/javascript">stLight.options({publisher: "ur-3a946ea7-4e9c-2bf6-f820-37c233b1bc9c", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

And this goes in the body of the page.

<span class='st_sharethis_large' displayText='ShareThis'></span>
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_pinterest_large' displayText='Pinterest'></span>
<span class='st_email_large' displayText='Email'></span>

This did not work either.

<script type="text/javascript">var switchTo5x=true;</ script>
<script type="text/javascript" src=" w.sharethis/button/buttons.js"></ script> 
<script type="text/ javascript">
  stLight.options({
    publisher: "ur-3a946ea7-4e9c-2bf6- f820-37c233b1bc9c", 
    popup: 'true' 
    doNotHash: false, 
    doNotCopy: false, 
    hashAddressBar: false
 });
 </script>

I am using Sharethis button for social media sharing. The problem is that when you click on Twitter, Facebook, Linkedin or any other button, it open in new tab. I want it to open in popup window. Is that possible to do. Here is the code I am using.

This goes in head section

    <script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis./button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "ur-3a946ea7-4e9c-2bf6-f820-37c233b1bc9c", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

And this goes in the body of the page.

<span class='st_sharethis_large' displayText='ShareThis'></span>
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_pinterest_large' displayText='Pinterest'></span>
<span class='st_email_large' displayText='Email'></span>

This did not work either.

<script type="text/javascript">var switchTo5x=true;</ script>
<script type="text/javascript" src=" w.sharethis./button/buttons.js"></ script> 
<script type="text/ javascript">
  stLight.options({
    publisher: "ur-3a946ea7-4e9c-2bf6- f820-37c233b1bc9c", 
    popup: 'true' 
    doNotHash: false, 
    doNotCopy: false, 
    hashAddressBar: false
 });
 </script>
Share Improve this question edited Oct 10, 2014 at 14:57 mplungjan 178k28 gold badges181 silver badges240 bronze badges asked Oct 10, 2014 at 14:12 Mayank GuptaMayank Gupta 931 gold badge5 silver badges12 bronze badges 4
  • RTM: support.sharethis./customer/portal/articles/… – mplungjan Commented Oct 10, 2014 at 14:18
  • I tried this code which didn't work. please tell what I did wrong. <script type="text/javascript">var switchTo5x=true;</ script> <script type="text/javascript" src=" w.sharethis./button/buttons.js"></ script> ; <script type="text/ javascript">stLight.options({publisher: "ur-3a946ea7-4e9c-2bf6- f820-37c233b1bc9c", popup: 'true' doNotHash: false, doNotCopy: false, hashAddressBar: false});</script> – Mayank Gupta Commented Oct 10, 2014 at 14:48
  • You for sure forgot a ma after true,<<<< and you have a space after text/ and after </before script> – mplungjan Commented Oct 10, 2014 at 14:57
  • Plus it should be popup: true, not popup: 'true' – user3065931 Commented Apr 3, 2015 at 16:53
Add a ment  | 

3 Answers 3

Reset to default 12

Besides the popup option, you'll want to set the servicePopup option to true when calling stLight.options().

<script charset="utf-8" type="text/javascript" src="http://w.sharethis./button/buttons.js"></script>
<script charset="utf-8" type="text/javascript">
    stLight.options({
        "publisher":"####",
        "doNotCopy":false,
        "hashAddressBar":false,
        "doNotHash":false,
        "servicePopup":true
    });
</script>

I got this script working with ShareThis plugin, with:

"servicePopup":true

The problem is the button.js plugin that you are using.. If you had a link you could specify WHERE to open it, or with JS

window.open("www.youraddress.","_self")

But since you're using a pre-made plugin you can't change that.

You could create your own script to open a specific page on class click with something like

$('.stack').click(function(){
    window.location = 'www.stackoverflow.';
});

EDIT: Or as you can see from the ment on the question, that plugin supports option flags. My bad, haven't checked it.

发布评论

评论列表(0)

  1. 暂无评论