View PoPup with facebook page for users, show once every 7 days

0

<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/pt_BR/sdk.js#xfbml=1&version=v2.10";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="https://www.facebook.com/www.maroclub.net/" data-width="150" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>

This is the facebook code, a button for curti page, I want it to display after 10 seconds that the user opens the page. If you know a function that verifies if it already liked the page please add, because in that case it would only show if the user did not like what would be better.

    
asked by anonymous 17.10.2017 / 00:14

1 answer

0

The function that verifies if he already enjoyed it I do not know!

Library

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

HTML Modal

<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Modal</h4>
            </div>
            <div class="modal-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/pt_BR/sdk.js#xfbml=1&version=v2.10";
                  fjs.parentNode.insertBefore(js, fjs);
                }(document, 'script', 'facebook-jssdk'));</script>

                <div class="fb-like" data-href="https://www.facebook.com/www.maroclub.net/" data-width="150" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true">
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
            </div>
        </div>
    </div>
</div>

SCRIPT - comments in the code

//verifica se o cookie não existe ou se já está expirado 
if (document.cookie.indexOf("visita=") < 0) {  
    //abre o modal em 10 segundos
    setTimeout(function() {
        $('#myModal').modal();
    }, 10000);
   //grava cookie
   var date = new Date();
   //expira em 7 dias
   date.setTime(date.getTime()+(7*24*60*60*1000));
   var expires = "; expires="+date.toGMTString();

   document.cookie = "visita=realizada"+expires+"; path=/";

}
    
18.10.2017 / 14:47