基于用户的弹出窗口

User based pop up?

本文关键字:窗口 用户 于用户      更新时间:2023-09-26

基本上,我想找到一种方法来创建一个弹出窗口,提示用户一个问题,在窗口中我希望有一个复选框,上面写着"不再显示此消息"。我不太确定该怎么做,我做了一些研究,但一无所获,我很想知道如何帮助社区获得结果!

总之,我想要一个弹出窗口,检查用户是否"检查"不显示,然后它将不会执行该功能,该功能和jquery都很好。我可以做所有这些,但对于"每个用户"的请求,我不知道:(

我很乐意帮助你们!

对于弹出窗口,您可以使用Twitter Bootstarp Modol,这里是链接-http://twitter.github.com/bootstrap/javascript.html#modals。你也可以在modol中添加你的条件,并检查用户是否检查。

假设PHP:

$('.checkbox').on('change', function(){
   if($(this).is(':checked')){
       var doNotShow = TRUE;
       //the chekbox has been checked, the user does not want to see this again.
       $.ajax({
         url: 'path/to/my/controller.ext',
         data: 'doNotShow='+doNotShow,
         success: function(data){
           //the data has been sent to the server, close the popup box, do whatever is necessary here.
           // change the window location, whatever.
         }
       });
   }
});

服务器端PHP代码(路径/to/my/controller.ext)——

if(isset($_POST['doNotShow']) && $_POST['doNotShow'] == TRUE):
  $_SESSION['doNotShow'] = $_POST['doNotShow'];
endif;

现在,在加载该对话框之前,您需要添加一些PHP条件化它

<?php
if(!isset($_SESSION['doNotShow'])):
?>
    //javascript to launch the popup, the session is not set.
<?php
elseif(isset($_SESSION['doNotShow']) && ($_SESSION['doNotShow'] == TRUE)):
?>
    //don't launch the popup, they don't want to see it, whatever..
<?php
endif;