admin管理员组文章数量:1414878
I have a twitter share button that is created dynamically:
Html:
<a id="twitter_publish" href="" class="twitter-share-button" data-via="3imit" data-count="none"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Javascript:
function tweetSetup() {
$("#twitter_publish").remove();
$(".twitter-share-button").remove();
var tweet = $('<a>')
.attr('href', "")
.attr('id', "twitter_publish")
.attr('class', "twitter-share-button")
.attr('data-lang', "en")
.attr('data-via', "3imit")
.attr('data-count', "none")
.attr('data-text', "Take a look at this:")
.attr('data-url', $("#some_link").val())
.text('Tweet');
$("#facebook_publish").after(tweet);
twttr.widgets.load();
$("#twitter-share-button").show();
}
I would like to replace the default tweet icon with my own icon. How can I do that?
I have a twitter share button that is created dynamically:
Html:
<a id="twitter_publish" href="https://twitter./share" class="twitter-share-button" data-via="3imit" data-count="none"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter./widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Javascript:
function tweetSetup() {
$("#twitter_publish").remove();
$(".twitter-share-button").remove();
var tweet = $('<a>')
.attr('href', "https://twitter./share")
.attr('id', "twitter_publish")
.attr('class', "twitter-share-button")
.attr('data-lang', "en")
.attr('data-via', "3imit")
.attr('data-count', "none")
.attr('data-text', "Take a look at this:")
.attr('data-url', $("#some_link").val())
.text('Tweet');
$("#facebook_publish").after(tweet);
twttr.widgets.load();
$("#twitter-share-button").show();
}
I would like to replace the default tweet icon with my own icon. How can I do that?
Share Improve this question asked Mar 30, 2013 at 18:56 alexarshalexarsh 5,40112 gold badges44 silver badges53 bronze badges2 Answers
Reset to default 2Twitter has an example on how to do that here (scroll to bottom, "Build Your Own Tweet Button"):
<style type="text/css" media="screen">
#custom-tweet-button a {
display: block;
padding: 2px 5px 2px 20px;
background: url('https://twitter./favicons/favicon.ico') 1px center no-repeat;
border: 1px solid #ccc;
}
</style>
<div id="custom-tweet-button">
<a href="https://twitter./share?url=https%3A%2F%2Fdev.twitter.%2Fpages%2Ftweet-button" target="_blank">Tweet</a>
</div>
Check my answer on this question:
twitter button, with events and custom design
You can have a custom link and still use javascript API. For your case, your link should point to https://twitter./intent/tweet and you should add the query parameters you need to the url like this for example:
<a href="https://twitter./intent/tweet?url=http%3A%2F%2Fwww.yoururl.&text=your%20text">Tweet</a>
本文标签: javascriptReplace tweet button iconStack Overflow
版权声明:本文标题:javascript - Replace tweet button icon - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745213982a2648053.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论