本帖最后由 walunwine 于 2013-05-05 20:32:42 编辑

解决方案 »

  1.   

    要存入cookie已经看过了,cookie时间是跟随这个页面周期,cookie要另外找段代码处理,jquery没有cookie处理的方法。也可以存入session,在服务器端控制。
      

  2.   


    刚刚看了另外一个JS文件.不过是类似弹窗的.可是修改了一下还是改不出来.
    (function($){
       $.extend({
          top_shoussuo:function(option){
            var defaults={
            size:{width:300,height:200,padding:0,borderWidth:"1px"},
        title:{show:true,html:"Title"},
        content:{url:false,html:"Content"},
        skin:"js/top_shoussuo/default/top_shoussuo.css",
    minButton:true,
    openOnce:true,
    effect:{type:"fade",speed:"normal"}
         };  
     if(option)$.extend(true,defaults,option);
     //
     function writeCookie(name, value,keepTime) {
                     var expiresDate = new Date();
                     expiresDate.setTime(expiresDate.getTime() + keepTime);
                     var cookieStr = name + "=" + escape(value) + ";expires=" + expiresDate.toGMTString();
                     document.cookie = cookieStr;
             };
             function readCookie(name) {
                     var cookieStr = document.cookie;
                     var cookieArr = cookieStr.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
                     if (cookieArr != null) return unescape(cookieArr[2]); return null;
             };
         if(defaults.openOnce && readCookie("top_shoussuoOpen"))return;     
     //
     $("<link rel=\"stylesheet\" title=\"top_shoussuoSkin\" />").appendTo($("head")).attr("href",defaults.skin);
     //
     $("<div></div>").prependTo($("body")).attr("id","top_shoussuoWrap").css("display","none");
     var top_shoussuoWrap=$("#top_shoussuoWrap");  
     if(navigator.userAgent.toLowerCase().indexOf("msie 6")!=-1){
         var origBottom=$("body").height()-$(window).height();
     var origRight=$("body").width()-$(window).width();
     top_shoussuoWrap.css({position:"absolute",bottom:origBottom,right:origRight});
     $("body").css({position:"relative"});
     $(window).scroll(function(){
           top_shoussuoWrap.css({bottom:$("body").height()-$(window).height()-$(window).scrollTop(),right:$("body").width()-$(window).width()-$(window).scrollLeft()});
     });
     $(window).resize(function(){
           top_shoussuoWrap.css({bottom:$("body").height()-$(window).height()-$(window).scrollTop(),right:$("body").width()-$(window).width()-$(window).scrollLeft()});
     });
     }else{
         top_shoussuoWrap.css({"position":"fixed",bottom:"0px",right:"0px"});  
     }
     top_shoussuoWrap.css({zIndex:"999",overflow:"hidden",width:defaults.size["width"],height:defaults.size["height"],padding:defaults.size["padding"],borderWidth:defaults.size["borderWidth"],background:"#fff"});
     //
     $("<div></div>").prependTo(top_shoussuoWrap).attr({"id":"top_shoussuo","class":"top_shoussuo-"+new Date().getTime()}).css("position","relative");
         var myBox=$("#top_shoussuo");
     //
     if(defaults.title["show"]){
        $("<h6></h6>").prependTo(myBox).attr("class","top_shoussuo-title").html(defaults.title["html"]);
    var myBoxTitle=myBox.children("h6.top_shoussuo-title");
     }else{
        defaults.minButton=false;
     }
     //
     var skinPath=defaults.skin.match(/[^\/]*\/?top_shoussuo\/[^\/]+\//);
             $("<span></span>").prependTo(myBox).attr("class","top_shoussuo-close").append("<img alt=\"\" src=\""+skinPath+"close.gif\" />").css("position","absolute");  
     //bind event
     myBox.children("span.top_shoussuo-close").children("img").bind("click",function(){
            setWinStatu("hide");
     });
     if(defaults.minButton){
        $("<span></span>").prependTo(myBox).attr("class","top_shoussuo-min").append("<img alt=\"\" src=\""+skinPath+"min.gif\" />").css("position","absolute");
        myBox.children("span.top_shoussuo-min").children("img").click(function(){
         var me=$(this);
     if(!top_shoussuoWrap.is(":animated") && top_shoussuoWrap.height()==defaults.size["height"]){
          top_shoussuoWrap.animate({height:myBoxTitle.outerHeight()-parseInt(myBoxTitle.css("borderBottomWidth"))},function(){
            me.attr("src",skinPath+"max.gif");
      });
     }else{
         top_shoussuoWrap.animate({height:defaults.size["height"]},function(){
            me.attr("src",skinPath+"min.gif");
     });
     }
        });
     };
     //
     $("<div></div>").appendTo(myBox).attr("class","top_shoussuo-content");
     var myBoxContent=myBox.children("div.top_shoussuo-content");
     //
     if(defaults.content["url"]){
         myBoxContent.css("position","relative");
     $("<img />").appendTo(myBoxContent).attr({"src":skinPath+"load.gif","class":"top_shoussuo-load"});
     myBoxContent.load(defaults.content["url"]);
     }else{
         myBoxContent.html(defaults.content["html"]);
     }
     setWinStatu("show");
     writeCookie("top_shoussuoOpen","true",3600*1000);
     function setWinStatu(flag){
      switch(defaults.effect["type"]){
        case "slide":
    if(flag=="show")
      top_shoussuoWrap.slideDown(defaults.effect["speed"]);
        else if(flag=="hide")
      top_shoussuoWrap.slideUp(defaults.effect["speed"],function(){
          removeWin(); 
      }); 
    break;
    case "fade":
    if(flag=="show")
      top_shoussuoWrap.fadeIn(defaults.effect["speed"]);
        else if(flag=="hide")
      top_shoussuoWrap.fadeOut(defaults.effect["speed"],function(){
          removeWin();
      }); 
    break;
    case "show":
    if(flag=="show")
      top_shoussuoWrap.show(defaults.effect["speed"]);
        else if(flag=="hide")
      top_shoussuoWrap.hide(defaults.effect["speed"],function(){
          removeWin();
      });
    break;
       }
       function removeWin(){
              $("link[title='top_shoussuoSkin']").remove();
      top_shoussuoWrap.empty().remove(); 
       };
    }         
      } 
       });
    })(jQuery);
    这个的HMTL是
    <script language="javascript" type="text/javascript">
    $(document).ready(function(){
       $.eBox({
          title:{html:"新闻<span>-</span>热点"},
          content:{html:"<ul><li>最火</li></ul>"},
          effect:{type:"slide",speed:1500},
          openOnce:false
       });
    });
     /* Close window */
     function hideclosein2(){
    window.setTimeout("show_window2()",7000);
    }
    /* Show Window */
    function show_window2(){
      
     
    $('#eBoxWrap').animate({height:"26px"},1500);
    }
    hideclosein2()
    </script>
    真是弄的头都大了.
      

  3.   

    你可以仔细看一下这部分,用cookie判断是否执行特效。         function writeCookie(name, value,keepTime) {
                     var expiresDate = new Date();
                     expiresDate.setTime(expiresDate.getTime() + keepTime);
                     var cookieStr = name + "=" + escape(value) + ";expires=" + expiresDate.toGMTString();
                     document.cookie = cookieStr;
             };
             function readCookie(name) {
                     var cookieStr = document.cookie;
                     var cookieArr = cookieStr.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
                     if (cookieArr != null) return unescape(cookieArr[2]); return null;
             };
             if(defaults.openOnce && readCookie("top_shoussuoOpen"))return;