我正在使用一个名为Viral gate的脚本,用于在有人点击Facebook Like Box后解锁div内的内容,唯一的问题是div在脚本之前,所以当页面加载时在脚本被渲染之前,在5秒或更短时间内出现,具体取决于用户连接,换句话说,如果用户希望他可以在div出现时暂停页面,那么javascript将不会被渲染。 我尝试在head部分插入脚本,它没有用,也尝试在div之前用adl-inside-gate类插入它,结果相同。 这是我的脚本以及div和内容:
<div name="likebutton" style="padding-left: 370px; width:200px; padding-top:60px; position:relative;">
<!-- *** ADD THIS CODE AFTER YOUR PUBLIC CONTENT *** -->
<p class="adl-outside-gate">
<div class="adl-inside-gate" style="float:right">
<div class="linkado" style="width:130px; height:60px; background-color:#FF6600; border-width:4px; border-style:dashed; border-color:#FFFF00; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px;"> <a href="#" target="_blank">Clique aqui para visualizar o seu cupom.</a>
</div>
</div>
<div style="float:left"> <b><!-- Sharing buttons --></b>
<!-- Botões -->
<!-- Botões -->
<div>
<div>
<div id="fb-root"> <b><script src="http://connect.facebook.net/pt_BR/all.js#xfbml=1&appId=1667889836683276"></script><fb:like font="" href="http://lucrebem.com.br" layout="box_count" send="false" show_faces="false" width="55"></fb:like></b>
</div>
</div>
</div>
<!-- Botões -->
<!-- Botões --> <b><!-- Here is the code --><script type="text/javascript">
ADL = {};
(function(namespace) {
function ViralGate() { };
ViralGate.prototype.setDisplay = function(className, value) {
var els = document.getElementsByClassName(className);
for (var i = 0; i < els.length; i++) {
els[i].style.display = value;
}
};
ViralGate.prototype.lock = function() {
this.setDisplay('adl-outside-gate', 'block');
this.setDisplay('adl-inside-gate', 'none');
};
ViralGate.prototype.unlock = function() {
this.setDisplay('adl-outside-gate', 'none');
this.setDisplay('adl-inside-gate', 'block');
}
ViralGate.prototype.afterLike = function(event) {
// event is the URL
ADL.viralGate.unlock();
};
namespace.viralGate = new ViralGate();
})(ADL);
ADL.viralGate.lock();
FB.Event.subscribe('edge.create', ADL.viralGate.afterLike);
// Google callback must be in global namespace
afterPlus = function(data) {
ADL.viralGate.afterPlus(data);
}
</script></b>
</div>
答案 0 :(得分:0)
您需要将要默认隐藏的div的display css属性默认设置为“none”。类似的东西:
<div style="display: none"></div>
这将默认隐藏它,允许你的js稍后显示。