# Automatically redirecting to next step after displaying text or a progress bar

The below code can (or should be) placed inside a HTML (raw) element. It will then be loaded only when the form itself is loaded. Just make sure to uncheck the "Automatically add line-breaks" so that it doesn't corrupt the JavaScript code.

Inside the below code you can change the milliseconds 5000 to something different so it shows the text longer or shorter depending on your use case. Replace the `step===3` with the step number that is displaying the text or progress bar.

This code can of course be altered for other use cases as well. For questions you can always contact support.

<pre class="language-javascript"><code class="lang-javascript"><strong>&#x3C;script>
</strong><strong>(function(){
</strong>  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' &#x26;&#x26; 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);
  }
})();
&#x3C;/script>
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.super-forms.com/developers/code-examples/automatically-redirecting-to-next-step-after-displaying-text-or-a-progress-bar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
