SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup only once for BOTH entry and exit

    orking with a site that has a popup on entry to site and another on exit. The code below is a commonly used script to handle ensuring that the exit popup only occurs once per visit. But I can't quite make out how to modify this routine so that I could call it so that it handles both the entry poup and exit popup, so that both only occur once. Anyone have an idea?
    G
    <script>

    /*
    Fair well window launcher script
    By JavaScript Kit (http://javascriptkit.com)
    Over 200+ free scripts here!
    */

    function openpopup(){
    //configure "seeyou.htm and the window dimensions as desired
    window.open("seeyou.htm","","width=300,height=338")
    }

    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 loadpopup(){
    if (get_cookie('popped')==''){
    openpopup()
    document.cookie="popped=yes"
    }
    }

    </script>

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will have to set two cookies for this to work. Try creating two functions - loadpopup1() and loadpopup2() and then call one with the onload and the second with the onunload like this:
    function loadpopup1(){
    if (get_cookie('popped1')==''){
    openpopup()
    document.cookie="popped1=yes"
    }
    }
    function loadpopup2(){
    if (get_cookie('popped2')==''){
    openpopup()
    document.cookie="popped2=yes"
    }
    }
    window.onload=loadpopup1
    wondow.onunload=loadpopup2

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, ok, thanks!


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
  •