"Don't Show Again" button -JS/Cookie?

Posted on 2007-10-11
Last Modified: 2010-05-19
I'm looking for a script that will allow me to add a "Don't Show Again" button to an onUnload subscription offer (pop-up). I'd like it so that the  "Don't Show Again" script will load a cookie that will expire in three months so the notice will begin showing again.

The pop-up can be seen at Once you're on the page, leave it and the pop-up will (should) appear.

Here's the code for the pop-up:

<TITLE>Subscription Request</title>

<link href="global.css" rel="stylesheet" type="text/css">


<BODY bgColor="#CCCCCC">


<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">

<TR><TD align="center" valign="middle" height="100%">

<p class="serif_Geo fs_16 burg bold cent mT_0 mB_20">
Thank You!</p>

<p class="serif_Geo fs_13 blue cent mT_8 lH_18 width_400"> We hope you found your visit to<br>
<span class="burg bold fs_13">The Catholic World</span><br>enjoyable & informative. Before leaving we would like to invite you to subscribe and receive bi-monthly updates. All that  is needed is your name and email address.</p>

 <input type="hidden" name="redirect"
        value="thank_you.htm" target="new" />
         <input type="hidden" name="required" value="" />
            <input type="hidden" name="recipients" value="," />
          <input type="hidden" name="missing_fields_redirect"
        value="../form_error/form_error.html" />
         <input type="hidden" name="subject"
        value="TCW Subscription" />
<input type="text" id="first_name" name="First_Name" size="15" maxLength="50" value="[First Name]" onFocus="if (this.value=='[First Name]') this.value = '' ">
<input type="text" id="last_name" name="Last_Name" size="15" value="[Last Name]" maxLength="50" onFocus="if (this.value=='[Last Name]') this.value = '' "<br>
<input type="text" id="email" name="email" size="30" value="[E-Mail Address]" maxLength="50" onFocus="if (this.value=='[E-Mail Address]') this.value = '' "<br>

<input type="submit" id="subscribe" name="subscribe" value="Subscribe" class="burg fs_10 mT_6">
<input type="button" id="noThanks" name="noThanks" value="No Thanks" class="burg fs_10 mT_6 mB_12" onClick="window.close()">


Thanks for any and all help.

Question by:dcayce
    LVL 23

    Accepted Solution


    Cookies would be fine...

    You can use the cookie code here :

    With a few tweaks you can make it do what you desire...

    LVL 23

    Expert Comment

    note, you'd be better off checking the cookie BEFORE you popup the window, rather than checking it in the popup itself
    LVL 23

    Expert Comment

    so on the popup window you can add  this to the head:

    <script type="text/javascript">
    function setCookie(c_name,value,expiredays)
          var exdate=new Date()
          document.cookie=c_name+ "=" +escape(value)+
          ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())

    and add this button:

    <label for="dontbugme">Don't ask me again</label>
    <input id="dontbugme" type="checkbox" onclick="setCookie(, this.checked, 90);"/>

    Then, before you open the popup window you can check the "dontbugme" cookie.
    LVL 23

    Expert Comment

    you could use code like this to prevent the popup:

    <script type="text/javascript">
    function checkPopup()
     var dontbugme = getCookie('dontbugme');
     if(!(dontbugme == "true" || dontbugme == true))

    function getCookie(c_name)
       c_start=document.cookie.indexOf(c_name + "=");
       if (c_start!=-1)
        c_start=c_start + c_name.length+1
        if (c_end==-1) c_end=document.cookie.length
        return unescape(document.cookie.substring(c_start,c_end))
      return ""

    you would call it like this:
    <body onunload="checkPopup();">
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now