Hi Sio,

> But I've never used cookies before. Do you 
> have any code/ tutorial suggestions?

I'll give this a go, but I'm a copy 'n' paste javascripter and I've only had
one cup of coffee today, so it might go a bit wonky :-)

We need to set the cookie first. On the page that pops up, have a script in
the <head> that goes like this:

<script language="JavaScript">
  <!--
    function setCookie(name, value) 
    {
      var expires = new Date();
      expires.setTime(expires.getTime() + 365 * 24 * 60 * 60 * 1000); // one
year
      var curCookie = name + "=" + escape(value) + ("; expires=" +
expires.toGMTString() + "; path=/; domain=YOUR.DOMAIN.HERE");
      document.cookie = curCookie;
    }
  -->
</script>

You should replace "YOUR.DOMAIN.HERE", obviously, and you might want to
tweak the expiry time.

Call this function from the <body>'s onload event:

  <body onload="setcookie('survey',1);">

So when your popup window loads, it should set a cookie called "survey" with
a value of "1" on the visitor's computer (test it by setting your browser to
prompt you about all cookies, then visiting the page). 

Now you need to put the check for the cookie into the page that opens the
popup window, so in the <head> for that page, put the "getCookie" function:

<script language="JavaScript">
  <!--
    function getCookie(name) 
    {
      var dc = document.cookie;
      var prefix = name + "=";
      var begin = dc.indexOf("; " + prefix);
      if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
      } else begin += 2;
      var end = document.cookie.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin + prefix.length, end));
    }
  -->
</script>

I imagine that elsewhere on that page, you've got a script that launches
your window, something like this:

<script language="javascript">
  window.open('someurl.html');
</script>

All you have to do is check for the cookie before you do that:

<script language="javascript">
  if (getCookie('survey') != 1) {
    window.open('someurl.html');
  }
</script>


Shout if you run into problems!

HTH
Jon


____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to