Automatically redirecting to next step after displaying text or a progress bar
Below code is intended if you want to display a progress bar (or some text) like "Comparing the best offers for you……" inside a multi-part (form step) before automatically redirecting to the next step
<script>
(function(){
function hashChanged(storedHash){
if(storedHash.indexOf('#step-')===-1) return;
var currentStep = location.hash.substring(1);
if(currentStep!==''){
var form, explodedStep = currentStep.split('-');
if(explodedStep[0]==='step' && currentStep[4]==='-'){
var stepFormID = explodedStep[1];
form = document.querySelector('#super-form-'+stepFormID);
if(form.classList.contains('super-initialized')){
var multiPart = explodedStep[2].split(';');
var step = Number(multiPart[0]);
if(step===3){
// Redirect to step 4 after X seconds
setTimeout(function(){
debugger;
currentStep = 'step-'+stepFormID+'-'+(step+1);
window.location.hash = currentStep;
SUPER.switch_to_step_and_or_field(form, currentStep);
},5000);
}
}
}
}
};
if("onhashchange" in window) {
window.onhashchange = function () {
hashChanged(window.location.hash);
}
}else{
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
storedHash = window.location.hash;
hashChanged(storedHash);
}
}, 100);
}
})();
</script>Last updated