Scroll

Creating a Custom "Survey Offline" WebProd Page

Creating a Custom "Survey Offline" WebProd Page

Follow
Summary This article describes how to utilize Javascript to create a customized "Survey Offline/Unavailable" screen in WebProd
Applies to askiaweb
Written for Scriptwriters and Survey Authors
Keywords webprod; offline; script

Download example script here


Utilizing a combination of Javascript and HTML, it is possible to create a customized page that WebProd will redirect a respondent to in the case of a "103 Survey Offline" Error.

This is useful in the situation of invitation links having been sent to respondents, who may attempt to access them well after your survey has finished field.

Please Note: If your survey is offline, but still taking an active WebProd slot, the default "Offline" Final Page dictated in Askia Design WILL override this code.


Implementation

Placing this functionality into WebProd is relatively simple. Using the script provided, it can then be pasted into the "General Error Page" dialogue in the WebProd Configuration window:

 

The Javascript template will be used like this:

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

Error: ??WEBPROD_ERROR??.

<script>
$(document).ready(function(){
var foundin = $("body:contains(\"(cause 103)\")");
var bodyText = $("body").text();
var quote = unescape("%27");
var taskName = bodyText.substring(bodyText.indexOf(quote)+1,bodyText.lastIndexOf(quote));
var redirectURL = "/AskiaEndPage/" + "EndPage.htm";

if (foundin) {
checkIfRemoteFileExists(redirectURL);
}

function checkIfRemoteFileExists(url) {
$.ajax({
url:""+url+"",
error: function()
{
// do nothing; file does not exist
},
success: function()
{
window.location.href = url;
}
});
}
});

</script>

 

The code's functionality relies on looking for the "Cause 103" Default Error text to appear. Depending on this, the script will utilize an AJAX call to redirect the respondent to a pre-determined HTML page located on the Survey's respective Web machine by replacing the URL.

In this case, the HTML file was located under: 

C:\inetpub\wwwroot\AskiaEndPage\EndPage.htm

 

The code provided can also be altered by a survey programmer with a working knowledge of HTML/Javascript to further customize the function to suit the client's needs. 

Have more questions? Submit a request

Comments