samedi 5 août 2017

Retrieve url query string using javascript to resolve a if/else statement and redirect

I've read about 6 other posts on here about this topic and I still can’t seem to get this to work.

I want to use pure javascript to read a user defined url query string, then have it make a decision about where to redirect the user based on the information in the string.

I have the javascript saved in “script.js”, this is part of a webpage “http://ift.tt/2vzt09b”, the url with the query string would look like this “http://ift.tt/2uaKqFH”.

This is what my code looks like:

}
var birdtype = getQueryString('bird');
    if ( birdtype == [ chicken ])
        window.location.replace = "http://ift.tt/2vztr3p";
    else
        window.location.replace = "http://ift.tt/2uaiwcY";
};

Please, what am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire