How to pass a parameter like title, summary and image in a Facebook sharer URL

前端 未结 6 1786
故里飘歌
故里飘歌 2020-12-08 07:55

Question:

I need to pass my content like title, summary and image in a Facebook sharer URL like this:

 

        
6条回答
  •  猫巷女王i
    2020-12-08 08:00

    I've used the below before, and it has worked. It isn't very pretty, but you can alter it to suit your needs.

    The following JavaScript function grabs the location.href & document.title for the sharer, and you can ultimately change these.

    function fbs_click() {
            u=location.href;
            t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
                    'sharer',
                    'toolbar=0,status=0,width=626,height=436');
    
                return false;
            }
    

    Usage:

    
        Share on Facebook
    
    

    It looks like this is what you could possibly be looking for: Facebook sharer title / desc....

提交回复
热议问题