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 Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cookie limiting popup

    A few years ago I had a script that set a cookie to limit the number of times a popup window was opened for a particular viewer. All I can find now is a limit on the number of days. Anyone know where I can look?

  • #2
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Simply create a var that increments each time you write the cookie. If the var value exceeds your max, don't display the window. Search the net for Write Once Cookie.

    Vinny
    Where the world once stood
    the blades of grass
    cut me still

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or, if this is for sessions only you can use the window.name property to store the counter. The below two lines placed at the top of your popup function should work and not be disabled with cookies disabled....

    function popUp(){
    window.name = (window.name*1)+1;
    if(window.name > 3){ return false }


    // REST OF POPUP CODES HERE //

    }

    .....Willy

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    Or, if this is for sessions only you can use the window.name property to store the counter. The below two lines placed at the top of your popup function should work and not be disabled with cookies disabled....

    function popUp(){
    window.name = (window.name*1)+1;
    if(window.name > 3){ return false }


    // REST OF POPUP CODES HERE //
    Thanks, Willy. That looks like it will work.

  • #5
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    interesting willy... whats the logic behind the code?

    i assume it doesnt work if the user closes the browser and returns later, as it seems it isnt loading anything into the users temp files...

    if the user has his cache/temp files settings set to "download from server every time", does this still work?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by canadianjameson
    interesting willy... whats the logic behind the code?
    You can set and read the window.name property in IE3+, N3+...
    And if you set the window.name, you can read it back and use its value as you like....

    Quote Originally Posted by canadianjameson
    i assume it doesnt work if the user closes the browser and returns later, as it seems it isnt loading anything into the users temp files...
    Correct, it is session only. Once the browser is closed, you lost the session....

    Quote Originally Posted by canadianjameson
    if the user has his cache/temp files settings set to "download from server every time", does this still work?
    You are not downloading or placing anything on the users machine which, for sessions, I find the use of the window.name property more useful than cookies since cookies can be disabled.....

    .....Willy


  •  

    Posting Permissions

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