html 仅在用户通过Twitter,Facebook或Google+分享内容后才显示内容
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 仅在用户通过Twitter,Facebook或Google+分享内容后才显示内容相关的知识,希望对你有一定的参考价值。
<div id="fb-root"></div>
<script>
function showDiscountCode(response) {
// if they unliked you...
if (response && response.state === 'off') {
hideDiscountCode();
} else {
$('.discount-code').slideDown('slow');
}
}
function hideDiscountCode() {
$('.discount-code').slideUp('slow');
}
// load js for facebook
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// load js for g+
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
// load js for twitter
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
// sets up event listeners for when someone (un)likes the page
window.fbAsyncInit = function() {
FB.init({ appId: 'YOUR_APP_ID', status : true, cookie : true, xfbml : true });
FB.Event.subscribe('edge.create', function(response) { showDiscountCode(); });
FB.Event.subscribe('edge.remove', function(response) { hideDiscountCode(); });
};
// setup event listener for tweet callback
twttr.ready(function (twttr) {
twttr.events.bind('tweet', function(event) {
showDiscountCode();
});
});
</script>
<!-- the sharing buttons -->
<a href="https://twitter.com/share" data-text="Your tweet text" data-url="http://your-url-here.com" data-via="YourHandle" class="twitter-share-button" data-lang="en"></a><br>
<div class="fb-like" data-href="http://www.facebook.com/your_fb_page" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div><br>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="300" data-callback="showDiscountCode" data-href="http://your-url-here.com"></div><br>
<!-- the hidden content -->
<div class="discount-code">The discount code is: <strong>abcd1234</strong></div>
以上是关于html 仅在用户通过Twitter,Facebook或Google+分享内容后才显示内容的主要内容,如果未能解决你的问题,请参考以下文章
如何通过iOS中的Twitter API获取用户电子邮件地址?
Twitter Bootstrap 响应式 - 仅在桌面上显示表格列
Flutter 集成Facebook快捷登录
Twitter Bootstrap html 标签如何工作?
UIActivityViewController 自动“点击”链接 iOS 7
Twitter用户配置文件可以通过这个提取