How to redirect the user to other page in n seconds?
Question

I'm developing a register screen and i want the user to be redirected back to the homepage after 5 seconds, how can i do that? 

mvp_badge
MVP
Solution

Hi Lucca,

You can  do this in javascript:

"setTimeout(function(){ location='<url of the homepage>'; }, 5000);"

Replace the <url of the homepage> with the url that you want.

For traditional web app use a RunJavascript action in preparation.

For reactive Web use a JavaScript widget in OnInitialize event handler.

Regards,

Daniel

Lucca Beurmann wrote:

I'm developing a register screen and i want the user to be redirected back to the homepage after 5 seconds, how can i do that? 

Hello Lucca, you can do this in javascript with setTimeout()


https://www.w3schools.com/jsref/met_win_settimeout.asp


Example

"setTimeout(function(){ location='<url of the homepage>'; }, 3000);"

Hi Lucca,


I agree with the javascripts suggested above using 

setTimeout(function(){ location='<url of the homepage>'; }, 3000);


Also, You can check the forge component Delay. It supports both sync and async delays.

https://www.outsystems.com/forge/component-overview/2553/delay


Let me know if this helps.


Regards,

Saugat

JavaScript setTimeout(expression, timeout); runs the code/function once after the timeout. It is a time based code execution method that will execute script only one time when the interval is reached, and not repeat again unless you gear it to loop the script by nesting the setTimeout object inside of the function it calls to run. If geared to loop, it will keep firing at the interval unless you call clearTimeout(). If you want something to happen one time after some seconds Then use setTimeout... because it only executes one time when the interval is reached.

setTimeout(function() {

  console.log('Wait 3 seconds and I appear just once');

}, 3000);


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.