改进后的第一次访问弹出欢迎仿MSN通知的代码

每次访问都弹出有点太扰民了, 而且导致鼠标滚轮不可用. 现在改成访问时只在第一次弹出一次. 用 cookie 做判断.
<SCRIPT>
function WebFXCookie() {
    if (document.cookie.length) { this.cookies = ' ' + document.cookie; }
}

WebFXCookie.prototype.setCookie = function (key, value) {
    document.cookie = key + "=" + escape(value);
}

WebFXCookie.prototype.getCookie = function (key) {
    if (this.cookies) {
        var start = this.cookies.indexOf(' ' + key + '=');
        if (start == -1) { return null; }
        var end = this.cookies.indexOf(";", start);
        if (end == -1) { end = this.cookies.length; }
        end -= start;
        var cookie = this.cookies.substr(start,end);
        return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1));
    }
    else { return null; }
}
var webFXCookie = new WebFXCookie();
webFXCookie.setCookie("popupViewed", "yes");

if(webFXCookie.getCookie("popupViewed")  != "yes") {

      var oPopup;
      try {
      oPopup = window.createPopup();
      } catch(e) {
      window.status='弹出通知消息仅能用于 IE 下!';
      }

      var popTop=10;
      var mytime;

      function popmsg(msgstr){
      if(!oPopup) {
        return;
      }
      oPopup.document.body.innerHTML = msgstr;
      popshow();
      }

      function popshow(){
      //window.status=popTop;
      if(popTop > 1720){
      clearTimeout(mytime);
      oPopup.hide();
      return;
      } else if(popTop>=1720 - 108 && popTop<= 1720){
        oPopup.show(screen.width-200,screen.height, 193, 1720 - popTop);
      }else if(popTop>=1500 &&popTop< 1720 - 108){
      oPopup.show(screen.width-200, screen.height - 220  + (popTop - 1500), 193, 108);
      } else if(popTop<=108){
      oPopup.show(screen.width-200, screen.height, 193, popTop);
      } 
      else if(popTop<=220){
      oPopup.show(screen.width-200, screen.height-popTop, 193, 108);
      }else {
        //window.status=popTop + "  else";
        oPopup.show(screen.width-200, screen.height-220, 193, 108);
        //oPopup.parent.focus():
      }

      popTop += 10;
      mytime=setTimeout("popshow();", 40);
      }

      function hidePop() {
        clearTimeout(mytime);
        oPopup.hide();
      }

      popmsg("<div  οnclick='window.parent.hidePop()' title='点击隐藏' style='cursor:pointer; background-image: url(http://www.blogjava.net/images/blogjava_net/beansoft/18269/o_qqbg.gif); width:193; height:108; color:white; padding-top:1em; padding-left:5; font-size:11pt; color:white' ><center><b>BlogJava 系统通知<br><br>请留言或者捐款支持 BeanSoft 的 Java EE 学习视频!! </b></center></div>");

}

</SCRIPT>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值