Reputation: 502
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
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
Upvotes: 1
Views: 367
Reputation: 502
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&
count=none&
id=twitter-widget-0&
lang=en&original_referer='
+encodeURIComponent(referenceUrl)
+'&related=nothing%20to%20worry&size=m&
text=LiveImpact&
url='+encodeURIComponent(shareUrl)
+'" class="twitter-share-button twitter-count-none" title="Twitter Tweet Button" data-twttr-rendered="true" style="width: 56px; height: 20px;">'
+'</iframe>');
Upvotes: 2