Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery location href [duplicate]

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.

like image 266
Benjamin Avatar asked Aug 16 '11 13:08

Benjamin


2 Answers

There's no need for jQuery.

window.location.href = 'http://example.com'; 
like image 90
Dogbert Avatar answered Sep 16 '22 14:09

Dogbert


Use:

window.location.replace(...) 

See this Stack Overflow question for more information:

How do I redirect to another webpage?

Or perhaps it was this you remember:

var url = "http://stackoverflow.com"; location.href = url; 
like image 29
Curtis Avatar answered Sep 17 '22 14:09

Curtis