Support » Plugin: Selection Sharer by Hans van Gent » Facebook Opening in a Popup window and Title Issues

  • Resolved robertallen


    Both Twitter and Linked in open new windows when you click to share. Can we make Facebook do the same thing? Presumably it’s just switching the attribute value from _top to _blank?

    Also, when you share on Facebook or LinkedIn, the highlighted excerpt seems to replace the title. Would it be possible to adjust that so the title still shows up and the highlighted text get copied within quotes and placed within the comment box?

Viewing 10 replies - 1 through 10 (of 10 total)
  • For me, following changes made it work.

    File: plugins/selection-sharer/js/selection-sharer.js

    I changed below line:

    this.shareFacebook=function(e){e.preventDefault();var t=n.htmlSelection.replace(/<p[^>]*>/gi,”\n”).replace(/<\/p>| /gi,””).trim(),o=””+n.appId+”&display=page&name=”+encodeURIComponent(t)+”&link=”+encodeURIComponent(n.url2share)+”&redirect_uri=”+encodeURIComponent(n.url2share);window.location.href=o,,”share_linkedin”,”toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=”+w+”, height=”+h+”, top=”+top+”, left=”+left)},

    Changed line to below (changes in bold):

    this.shareFacebook=function(e){e.preventDefault();var t=n.htmlSelection.replace(/<p[^>]*>/gi,”\n”).replace(/<\/p>| /gi,””).trim(),o=””+n.appId+”&display=popup&name=”+encodeURIComponent(t)+”&link=”+encodeURIComponent(n.url2share)+”&redirect_uri=”+encodeURIComponent(n.url2share); var i=640,r=440,a=screen.width/2-i/2,l=screen.height/2-r/2-100; return,”share_facebook“,”toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=”+i+”, height=”+r+”, top=”+l+”, left=”+a)},

    Plugin Author jcvangent


    Hiya Robert, sorry for the late response. Indeed with the fix of hyesubba works. Will try to implement it in the live code soon (bit busy here) and will update the plugin.

    Thanks a lot @hyesubba for the help!


    Thread Starter robertallen


    Thank you so much for such a fast response. The only problem I see is on Facebook now it eliminated all spaces in the highlighted quote.

    Think of the last time you were at

    turns into


    Also, is there any way to display the article title upon all the social share postings as well?

    I was working on the first problem co-incidentally and happened to see this question, and so posted that solution alone here. Regarding the second problem, the problem of no spaces in title is not coming for me on my site. It may need some more checking about what is happening at your end.

    For title to be default title instead of selected text,
    can you try removing &name=”+encodeURIComponent(t)+” in the sentence. Then, facebook should take whatever you have in <title></title> tags in your html code. Or in case you have enabled facebook open graph tags, the og:title meta tag title would get reflected.

    For description, as per my understanding facebook does not provide any option to display what we want. It would display whatever is in description meta tag or og:description meta tag (in case you are embedding FB open graph tags). So, not sure if we can take to comments section the title.

    But, my experience may be limited, may be jcvangent can see if he has something.

    Plugin Author jcvangent


    @hyesubba is it possible to post your changes on ? WordPress messes up your entire code and makes it difficult to re-use it :-/

    edit: nevermind I think I got it by looking at the source of this page 🙂

    • This reply was modified 5 years, 2 months ago by jcvangent.
    Plugin Author jcvangent


    @hyesubba I tried your code and although it seems to work, it also gives me page refresh / rewrite to the FB share URL (so a pop-up and the page itself is gone), did you had the same issue? Did I ended copy’ing an typo from you maybe?


    That reply was almost one year ago, the version of plugin at that time might be old. We may have to freshly look at the problem, recent updates of FB and see what to do probably. Will let you know if I find anything.

    Plugin Author jcvangent


    @hyesubba yeah sorry for that one, thought it was resolved in a different way.. I can give you the current code I did yesterday with adding your code in there if that helps?

    Will do some more debugging myself as well in the mean time.

    Sure, you can provide.Is it this one –

    Plugin Author jcvangent


    The one, where I already added your code is located here:

    As you can see when you press Facebook share then it opens the pop-up but it also refreshes the page you are on to show the contents of the pop-up :-/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Facebook Opening in a Popup window and Title Issues’ is closed to new replies.