This code also work in jQuery code.
You can try below methods –
Redirection : A page automatically goes to another page then it is called a redirection. The redirection of a web page is used for different reasons.
If you want to redirect to a different path or page, on the same domain-
window.location.pathname = '/other'
window.location = 'https://test.com'
Other options to redirect
You can also try below method-
location = 'https://test.com'
Another method is to set the href property of location-
window.location.href = 'https://test.com'
Location also has an assign() method that accepts a URL, and performs the same thing-The most common way to redirect an URL using jQuery
Different ways to reach the window object-
self.location = 'https://test.com' top.location = 'https://test.com'
$(location).attr('href',"http://www.google.com"); $jq(window).attr("location","http://www.google.com"); $(location).prop('href',"http://www.google.com");
Related technical blogs – Technical Tag