如何设置饼干敌人通知栏



我有一个通知栏的代码,我需要,当用户第一次运行页面时,它会显示通知栏,当用户刷新页面时它不会显示。

这是我使用的代码,

<div id="page-wrap">
    <div id="note">
        You smell good. <a id="close">[close]</a>
    </div>
    <h1>Pop From Top Message</h1>
    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis </p>
    </div>

Jquery:

 <script>
   close = document.getElementById("close");
   close.addEventListener('click', function() {
     note = document.getElementById("note");
     note.style.display = 'none';
   }, false);
  </script>

这是jsfiddle:http://jsfiddle.net/t90096vs/

我如何添加饼干来解决这个问题。

谁能帮我?提前谢谢。

$(function() {
    function GetCookie(name) {
        var arg=name+"=";
        var alen=arg.length;
        var clen=document.cookie.length;
        var i=0;
        while (i<clen) {
            var j=i+alen;
                if (document.cookie.substring(i,j)==arg)
                    return "here";
                i=document.cookie.indexOf(" ",i)+1;
                if (i==0) 
                    break;
        }
        return null;
    }
    var visit = GetCookie("showed_note");
    if (visit == null) {
        $("#note").show();
        document.cookie = "showed_note=true";
    } else {
        $("#note").hide();
    }
});

演示

最新更新