Shaun
Shaun

Reputation: 4177

Use jQuery to navigate away from page

I will only have a relative link available to me but I want to use jQuery to navigate to this rel link. I only see AJAX functionality in jQuery. How can I do this using jQuery or just pure HTML/JavaScript?

Upvotes: 44

Views: 110965

Answers (3)

qbantek
qbantek

Reputation: 705

window.location = myUrl;

Anyway, this is not jQuery: it's plain javascript

Upvotes: 7

Ken Browning
Ken Browning

Reputation: 29101

Other answers rightly point out that there is no need to use jQuery in order to navigate to another URL; that's why there's no jQuery function which does so!

If you're asking how to click a link via jQuery then assuming you have markup which looks like:

<a id="my-link" href="/relative/path.html">Click Me!</a>

You could click() it by executing:

$('#my-link').click();

Upvotes: 14

NickFitz
NickFitz

Reputation: 35051

window.location.href = "/somewhere/else";

Upvotes: 182

Related Questions