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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code for one-time only pop up

    I found this code on a very useful site, javascriptkit.com.

    How do I change this from a 'once per session' pop up to 'one time only'? Is it as simple as changing (once_per_session==0) to (one-time-only==0)

    You can view it on my website: www.polarisgolf.eu

    I would be very grateful if anyone could help me with this.

    <script>

    //Alert message once script- By JavaScript Kit
    //Credit notice must stay intact for use
    //Visit http://javascriptkit.com for this script

    //specify message to alert
    var alertmessage="We use cookies to make our website work properly. See the links page for details."

    ///No editing required beyond here/////

    //Alert only once per browser session (0=no, 1=yes)
    var once_per_session=1


    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 alertornot(){
    if (get_cookie('alerted')==''){
    loadalert()
    document.cookie="alerted=yes"
    }
    }

    function loadalert(){
    alert(alertmessage)
    }

    if (once_per_session==0)
    loadalert()
    else
    alertornot()

    </script>

  • #2
    New Coder
    Join Date
    Aug 2010
    Location
    myeik
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 5 Posts
    var once_per_session=1
    need to change 1 to 0

    like this ?

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks.

    You said 'like this?', so I take it you're not sure and you're taking a guess?

    I could try it on a test page if you're not 100% sure.


  •  

    Posting Permissions

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