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

    Show javascript ad only once per day

    Hey guys, I already saw this post but I wasn't sure if it took care of the question I'm asking.

    I have the following javascript ad code right before the </body> tag:

    Code:
    <script type="text/javascript" src="http://ads.affbuzzads.com/smart_ad/display?ad_unit=18&ref=xxxxx"></script>
    This is a slider ad that shows every time the person comes to the page I have it on.

    I'd like to show this ad only once per 24 hours per visitor.

    Can someone please help me out with code to do this? I'm kinda newbish at this.

    Thanks so much!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    (1) Look to see if a cookie you previously set is there.
    (2) If it is, look to see if it contains today's date.
    (3) If *NOT*, then:
    -- (3.a) write out the JS script code you showed so the ad appears.
    -- (3.b) Set the cookie in place, giving it a value of today's date

    I won't bother showing you the setCookie and getCookie code, as you can find them all over the place. (Try "w3c javascript cookies" in google, for example.)

    And, yes, you can use JavaScript to document.write other JS code. Or you can use a script object, if you want to be more modern.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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