BeanSoft's Java Blog
MyEclipse 6, Java EE 5, Spring, Struts, Hibernate, JPA, SWT, WebLogic, AJAX, JavaScript, Netbeans 6
每次访问都弹出有点太扰民了, 而且导致鼠标滚轮不可用. 现在改成访问时只在第一次弹出一次. 用 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  onclick='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>
 
 
posted on 2007-10-26 11:06 BeanSoft 阅读(1242) 评论(1)  编辑  收藏 所属分类: AJAX
Comments
  • # re: 改进后的第一次访问弹出欢迎仿MSN通知的代码
    LifeNote
    Posted @ 2007-12-12 10:01
    哈哈 这个好玩 多谢分享  回复  更多评论