SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Popup Cookie

  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup Cookie

    Hi,

    I plan to have a popup load once per session for IE6 users extolling the virtues of either IE7 or Firefox. Below is the code, loaded in <body> that I want to use, but I can't seem to get it to work. Anyone have any idea?

    Code:
    <script type="text/javascript">
    
    function openpopup(){
    	AJS.AEV(window, 'load', function() {GB_showCenter("", "http://www.oxidephoto.ca/upgrade.htm", 380,420);});
    }
    
    function get_cookie(Name) {
      var search = Name + "=";
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) { // if cookie exists
          offset += search.length;
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1)
             end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end));
          }
       }
      return returnvalue;
    }
    
    function loadornot(){
    if (get_cookie('jkpopup')==''){
    openpopup();
    document.cookie="jkpopup=yes";
    }
    }
    
    loadornot();
    </script>
    Thanks!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    I replaced the AJS.AEV with a simple alert for testing purposes, and the rest of the code worked fine for me. Got a warning the first time and not again since.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •