简体   繁体   English

Facebook和Twitter分享按钮中的自定义URL

[英]Custom URL in facebook and twitter share button

I want to share a particular link when clicked on a share button in my app. 我想在我的应用程序中单击共享按钮时共享特定链接。 Facebook share button snipet Facebook分享按钮snipet

<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

How do i input my custom url? 我如何输入我的自定义网址?

Change location.href to whatever URL you want to share. location.href更改为您要共享的任何URL。

For example: 例如:

<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent('http://google.com'), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM