Call toll free 1.866.218.5127

Javascript Redirect Code – Redirect Users to Another Page

Every now and then, you’ll want to send one of your users to an external website.  You can already do this by using the redirect settings on your publish page. If you are looking to skip to a particular page within your survey, you should use simple survey skipping. However, using those settings, what you will not be able to do is redirect someone to an external website from somewhere in the middle of your survey. In order to do this, you will have to paste some javascript code into your survey.

To get an idea of what you can use this for, let’s say that on the first page of your survey, you were to ask: “which one of the following websites would you like to visit?”

Your answer choices could be:

1) cnn.com

2) myreviewroom.com

3) chide.it

4) twitter.com/fluidsurveys

What you can then do at that point, is use simple survey skipping to send the user to a different page based on their responses to this question. For the sake of example, we will send users to page 2 if they choose cnn.com, page 3 if they choose myreviewroom.com, page 4 if they choose chide.it, and page 5 if they choose twitter.com/fluidsurveys.

Now, what we need to do is paste the following code on each of these pages:

<script type=”text/javascript“>
<!–
/* Set the following variable to the page you would like to redirect to */
var redirectLocation = “http://google.com“;
/* Set the desired wait time (in milliseconds) */
var delay = 5000;
$(window).load(function(){
setTimeout(function(){
window.location = redirectLocation;
}, delay);
});
//–>
</script>
This code must be pasted into a “section separator”. You should then modify the number “5000″ to represent the number of milliseconds that the user’s browser should wait before they are redirected to the destination page. You also must specify the destination url by changing the url that currently points to http://google.com in the javascript code. In other words, you have to customize this javascript code on pages 2,3,4, and 5 of your survey.
1-877-230-8724
Posted in: Blog

Share this

2 Comments to "Javascript Redirect Code – Redirect Users to Another Page"

  1. Patrick Drost

    June 22, 2012

    I tried throwing this code into one of the section separators and couldn’t get it to work in IE or Chrome.  Is there something I’m missing?

    Reply
    • fluidsurveys

      June 22, 2012

      Hi Patrick,

      If you could send an email to support@fluidsurveys.com with the link to your survey, we can certainly help you figure this one out! Our support team is super fast and responsive, so you’ll get an answer in no time!

      Reply

Leave a Comment

CommentLuv badge