Redirect using jQuery

Javacsript and jquery

Redirect To Another URL Using JQuery Or JavaScript,Using plain JavaScript there are different way to redirect the user to a different web page.
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.

The JavaScript and jQuery are mostly used for client side redirection after some operation and there are a below number of ways to redirect a web page using JavaScript In this post

If you want to redirect to a different path or page, on the same domain-

window.location.pathname = '/other'

If you want to redirect to a new URL- The most common way to redirect an URL using JavaScript

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

window.location.assign('https://test.com')
window.location.replace('https://test.com')

Different ways to reach the window object-

self.location = 'https://test.com'
top.location = 'https://test.com'

Using jQuery:

 $(location).attr('href',"http://www.google.com");
 $jq(window).attr("location","http://www.google.com");
 $(location).prop('href',"http://www.google.com"); 

All above aboyt to redirect To Another URL Using JQuery Or JavaScript

Related technical blogs – Technical Tag

Like us on Facebook and Linkedin for more updates.

Back To Top