Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with pop up window script

    I am using the following script on my site to load a popup ad.. However I want it to open only once...Not every visit to the page.. How do I configure the script to do this?

    Here it is -

    <script>

    //Popup Window Script
    //By JavaScript Kit (http://javascriptkit.com)
    //JavaScript tutorials and over 400+ free scripts

    function openpopup(){
    var popurl="ccad.html"
    winpops=window.open(popurl,"","width=531,height=370,")
    }

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

    loadornot()
    </script>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That should work if they don't close their browser down, open it back up and go to the page. The script sets a cookie so that is won't open up again within the same browser session. Is that not working?

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes it is working for the session but I do not want a session cookie I want it show only once ever and then not again...

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will need to add an expiration date to the cookie. try this link for an explanation on how to do it:
    http://devedge.netscape.com/library/...e/cookies.html

    It is old, but still relavent.

  • #5
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the information - the one page ont he site keeps crashing my browser...

    How would I configure the code that I have? Or would I have to use a totally different script?

    Thanks for all your help!

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I wouldn't use pop-ups...Everybody is turning them off.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

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