我正在使用一个名为 Viral Gate 的脚本,它用于在有人点击 Facebook Like Box 后解锁 div 内的内容,唯一的问题是 div 出现在脚本之前,所以当页面加载时它出现在脚本在 5 秒或更短的时间内被渲染,具体取决于用户连接,换句话说,如果用户希望他可以在 div 出现时暂停页面,那么 javascript 将不会被渲染。我尝试在 head 部分插入脚本,它没有工作,还尝试在具有 adl-inside-gate 类的 div 之前插入它,结果相同。这是我的脚本以及 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>