Web Analytics Made Easy -
StatCounter Show javascript ad only once per day - CodingForum


No announcement yet.

Show javascript ad only once per day

  • Filter
  • Time
  • Show
Clear All
new 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:

    <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
    (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.
    Be yourself. No one else is as qualified.