我想在覆盖 div(页面底部)中显示 Facebook 的点赞按钮,但是还有一些额外的请求使它变得复杂。
- 访问者在生成第二个页面视图时会看到它(他们来到网站并至少再打开一个页面)
 - 它应该只出现一次
 - 它应该只显示大约 20 秒(或任何其他秒数)或直到您单击“x”按钮
 - 它前面会有一个简短的文本(欢迎来到 Example.com...)。理想情况下,所有内容都在此代码中,无需从页面中提取额外的 DIV。
 
我设法创建了一个关闭按钮。这是代码:
$(document).ready(function(){
    $('#closebutton').click(function(){
        $('#facebookdiv').remove();
        $(this).remove();
        document.cookie="removeit=yes";
    });    
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
      x=x.replace(/^\s+|\s+$/g,"");
        if (x=="removeit")
       {
        $('#facebookdiv').remove();
        $('#closebutton').remove();
        }
      }
});
这可以实现吗?如何实现?这是一个带有一些我正在试验的代码的 jsFiddle:http: //jsfiddle.net/tj8N6/3/
先感谢您!
编辑
我当前测试 HTML 页面的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
<script type="text/javascript" src="http://http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.cookie('fbbox', '1', { path: '/', domain: 'www.example.com' });
if($.cookie('fbbox') == null) { 
    $.cookie('fbbox', '1', {expires:7, path:'/'});
}
if($.cookie('fbbox') == 1) { 
    $.cookie('fbbox', '2', {expires:7, path:'/'});
}
});
var buttonShowTime=20000;
if (fbbox == '2') {
    $('#facebookdiv').show();
    setTimeout(function() {
        $('#facebookdiv').hide();
    }, buttonShowTime);
}
</script>
</head>
<body> 
<div id="fb-root"></div>
<script>(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/es_ES/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id="facebookdiv">
<div class="fb-like" data-href="https://www.facebook.com/stackoverflowpage" data-send="false" data-width="450" data-show-faces="false" data-colorscheme="dark" data-font="arial"></div>
<div id="closebutton">X</div>
</div>
</body> 
</html>