jQuery location href
JavascriptJqueryJavascript Problem Overview
I remember there's a redirect function in jQuery.
It was like:
$(location).href('http://address.com')
But what was it exactly? I couldn't remember and can't find it using Google Search.
Javascript Solutions
Solution 1 - Javascript
There's no need for jQuery.
window.location.href = 'http://example.com';
Solution 2 - Javascript
Use:
window.location.replace(...)
See this Stack Overflow question for more information:
https://stackoverflow.com/questions/503093/
Or perhaps it was this you remember:
var url = "http://stackoverflow.com";
location.href = url;
Solution 3 - Javascript
This is easier:
location.href = 'http://address.com';
Or
location.replace('http://address.com'); // <-- No history saved.
Solution 4 - Javascript
I think you are looking for:
window.location = 'http://someUrl.com';
It's not jQuery; it's pure JavaScript.
Solution 5 - Javascript
Ideally, you want to be using window.location.replace(...)
.
See this answer here for a full explanation: https://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery
Solution 6 - Javascript
You can use just JavaScript:
window.location = 'http://address.com';