redirect?

Discussion in 'JavaScript' started by webcutie, Jul 18, 2007.

  1. #1
    Probably a dumb question, I'm new to this so please be nice!



    How would I set a cookie and then redirect to another page. I want to use this for an affiliate website. I put the affiliate code in the form which cookies them, then I want to redirect them to the page with the promo material. How would I do the redirection part in here??





    This is what I'm using:

    <SCRIPT LANGUAGE="JavaScript">

    cookie_name = "dataCookie";
    var YouEntered;

    function putCookie() {

    if(document.cookie != document.cookie)
    {index = document.cookie.indexOf(cookie_name);}
    else
    { index = -1;}

    if (index == -1)
    {
    YouEntered=document.cf.cfd.value;
    document.cookie=cookie_name+"="+YouEntered+"; expires=Monday, 04-Apr-4000 05:00:00 GMT";
    }

    }
    </SCRIPT>



    <FORM NAME="affiliate">
    Cookie:
    <INPUT TYPE="text" NAME="affiliate" size="20">
    <INPUT TYPE="button" Value="Set Cookie"
    onClick="putCookie()">

    </FORM>


    Any help would be great
     
    webcutie, Jul 18, 2007 IP
  2. ds316

    ds316 Peon

    Messages:
    154
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should place the code at the end of putCookie, and the code should be something along the lines of:

    window.location.href = "http://newurl";
     
    ds316, Jul 22, 2007 IP