简体   繁体   中英

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

i have a twitter img with onclick function tweetpage

<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. clicking on the tweet button a twitter popup box is shown but the url in textbox contains only

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

how can i solve this.

I also tried

&hashtags= instead of #

the result was

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.)

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>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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