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

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 http://www.thecatholicworld.com. Once you're on the page, leave it and the pop-up will (should) appear.

Here's the code for the pop-up:


<HTML>
<HEAD>
<TITLE>Subscription Request</title>

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

</head>

<BODY bgColor="#CCCCCC">

<CENTER>

<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>

<FORM METHOD="POST" ACTION="FormMail.pl">
 <input type="hidden" name="redirect"
        value="thank_you.htm" target="new" />
         <input type="hidden" name="required" value="" />
            <input type="hidden" name="recipients" value="cayce@paulistpress.com,mkerrigan@paulistpress.com" />
          <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">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" id="noThanks" name="noThanks" value="No Thanks" class="burg fs_10 mT_6 mB_12" onClick="window.close()">
</form>
</td></tr>
</table>


</center>
</body>
</html>




Thanks for any and all help.

Cayce
dcayceAsked:
Who is Participating?
 
basicinstinctCommented:
Hi

Cookies would be fine...

You can use the cookie code here :

http://www.w3schools.com/js/js_cookies.asp

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

0
 
basicinstinctCommented:
note, you'd be better off checking the cookie BEFORE you popup the window, rather than checking it in the popup itself
0
 
basicinstinctCommented:
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()
      exdate.setDate(exdate.getDate()+expiredays)
      document.cookie=c_name+ "=" +escape(value)+
      ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
</script>


and add this button:


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


Then, before you open the popup window you can check the "dontbugme" cookie.
0
 
basicinstinctCommented:
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))
 {
       window.open('subscript_pop.html','window',config='width=750,height=600,location=yes,status=yes');
 }
}

function getCookie(c_name)
{
  if(document.cookie.length>0)
  {
   c_start=document.cookie.indexOf(c_name + "=");
   if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    }
  }
  return ""
}
</script>


you would call it like this:
<body onunload="checkPopup();">
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.