Santo Boldizar
Santo Boldizar

Reputation: 1395

How to redirect a page in Drupal 8 after seconds?

I used:

$response = new\Symfony\Component\HttpFoundation\RedirectResponse('/new_page');
$response->send();

But here I do not have options to redirect e.g after 5s.

P.S. header( "refresh:5;url=/new_page" ); is not a great idea, I am looking for a Drupal 8 option. Thanks. :)

Upvotes: 0

Views: 1370

Answers (1)

gd_silva
gd_silva

Reputation: 1025

That should be done in the frontend, through JavaScript's setTimeout() function.

Example

setTimeout(
    function() {
        window.location = "http://www.yoururl.com";
    }, 5000
);

Upvotes: 2

Related Questions