简体   繁体   English

如何使用tweet_button.html在Twitter中与#共享URL

[英]how to share a url with # in twitter using tweet_button.html

i have a twitter img with onclick function tweetpage 我有一个带有onclick功能tweetpage的Twitter img

<img src="images/twtr.png" onclick="tweetPage();"/>

function tweetPage()
{
  var url = "http://www.website.com/index.html#eyJkIjoidGhpcyBpcyBh";
  var testUrl ="https://platform.twitter.com/widgets/tweet_button.html?url="+url
  var htmlStr = '<iframe allowtransparency="true" frameborder="0" scrolling="no"'
              +'src="'+testUrl+'"'
              +'style="width:130px; height:20px;padding-top: 37%;"></iframe>'
  $('#twitLindDiv').html(htmlStr);
}

and a tweetbutton is shown. 并显示一个tweetbutton。 clicking on the tweet button a twitter popup box is shown but the url in textbox contains only 单击tweet按钮,会显示一个twitter弹出框,但文本框中的url仅包含

http://www.website.com/index.html http://www.website.com/index.html

how can i solve this. 我该如何解决。

I also tried 我也试过

&hashtags= instead of # &hashtags =代替#

the result was 结果是

http://www.website.com/index.html #eyJkIjoidGhpcyBpcyBh http://www.website.com/index.html #eyJkIjoidGhpcyBpcyBh

how can i solve this 我该如何解决


tweetid is the div to which this inner html is added (this works fine for me.) tweetid是向其添加此内部html的div(对我而言效果很好)。

var referenceUrl = window.location.toString();
var shareUrl = 'http://www.website.com/index.html#eyJkIjoidGhpcyBpcyBh'
$('#tweetid').html('<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.1368146021.html#_=1369640770351&amp;
count=none&amp;
id=twitter-widget-0&amp;
lang=en&amp;original_referer='
+encodeURIComponent(referenceUrl)
+'&amp;related=nothing%20to%20worry&amp;size=m&amp;
text=LiveImpact&amp;
url='+encodeURIComponent(shareUrl)
+'" class="twitter-share-button twitter-count-none" title="Twitter Tweet Button" data-twttr-rendered="true" style="width: 56px; height: 20px;">'
+'</iframe>');

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

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