Facebook popup remember when user likes

最后都变了- 提交于 2019-12-23 06:21:09

问题


I've implemented a code on my page that displays a facebook like popup. I've inserted this code in my website

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'></script>
<script src="https://gj37765.googlecode.com/svn/trunk/html/[www.gj37765.blogspot.com]jquery.colorbox-min.js"></script>
<link rel="stylesheet" href="https://gj37765.googlecode.com/svn/trunk/html/%5Bwww.gj37765.blogspot.com%5Dfbpopup.css" type="text/css" />
<script type="text/javascript">
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
if (document.cookie.indexOf('visited==false') == -1) {
var fifteenDays = 1000*60*60*24*30;
var expires = new Date((new Date()).valueOf() + fifteenDays);
document.cookie = "visited=true;expires=" + expires.toUTCString();
$.colorbox({width:"400px", inline:true, href:"#mdfb"});
}
});
</script>
<div id="mdfb" style='padding:10px; background:#fff;'>
<h3 class="mdbox-title">Кликни LIKE и стани наш фан да бидеш известен на твојот профил за сите попусти!<center><p style="line-height:3px;" >?</p></center></h3>
<center>
<iframe id="fb-like" src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fshoppingkatalog&amp;width=300&amp;colorscheme=light&amp;show_faces=true&amp;border_color=%23ffffff&amp;stream=false&amp;header=false&amp;height=258" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:258px;" allowtransparency="true"></iframe>
</center><p style=" float:right; margin-right:35px; font-size:9px;" >Powered By <a style=" font-size:9px; color:#3B78CD; text-decoration:none;" href="http://www.shoppingkatalog.com">Шопинг Каталог</a></p>
</div>

Now I need to remember when a user clicks like, I need to create cookie or something like that to remember which user has liked my page, and who not. If a user didn't like my page on facebook display the popup again, if the user has pressed like do not show this popup again. Can anybody tell me how to solve this problem?


回答1:


If you want to do it on the client side, look into localStorage:

To set the value:

localStorage.setItem('liked', 'true');

To get the value:

value = localStorage.getItem('liked');

If you must support older browsers, here's an article on cookies that I found useful.



来源:https://stackoverflow.com/questions/11343687/facebook-popup-remember-when-user-likes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!