[英]Load Twitter Follow button inside hidden div
I've basically run into the same issue as this topic (http://stackoverflow.com/questions/9662576/social-media-buttons-inside-hidden-div) but as the poster scrapped the code before sharing I was hoping someone would have a solution. 我基本上遇到了与此主题相同的问题(http://stackoverflow.com/questions/9662576/social-media-buttons-inside-hidden-div)但是由于海报在分享之前废弃了代码我希望有人会有一个解决方案。
I'm loading a set of social media icons in a hidden div, which become visible when hovered. 我正在隐藏的div中加载一组社交媒体图标,这些图标在悬停时变得可见。 The issue seems to be that as the Follow button is loaded in a hidden div, it doesn't append the @username but simply displays "Follow".
问题似乎是,当Follow按钮加载到隐藏的div中时,它不会附加@username,而只是显示“Follow”。
Any help would be highly appreciated! 任何帮助将非常感谢!
This should reproduce the issue for you; 这应该为您重现问题;
HTML: HTML:
<li><a class="menu">Menu Item</a>
<ul id="blah-menu">
<a href="https://twitter.com/twitter" class="twitter-follow-button" data-show-count="false" data-dnt="true">Follow @twitter</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.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</ul>
</li>
CSS: CSS:
nav li ul#blah-menu {
display: none;
z-index: 99999 !important;
}
nav li:hover ul#blah-menu {
display: block;
height: auto;
position: absolute;
z-index: 1;
}
我最后在页脚的某处显示了1x1(和溢出:隐藏)div包装器,并且当按钮应该显示时,只需将包装器移动到所需位置并设置溢出:可见
I had similar problem. 我有类似的问题。 I soved it using setinterval.
我用setinterval来推它。
var twitterListener = setInterval(function(){
if(jQuery("#yourDiv").is(":visible")){
clearInterval(twitterListener)
if (typeof window.twttr == "undefined") {
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="https://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"));
}
twttr.ready(function (twttr) {
twttr.events.bind('click', function (event) {
//
});
twttr.events.bind('follow', function(event) {
//
});
twttr.events.bind('tweet', function(event) {
//
});
});
}
},10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.