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 DHTML/javascript?
+2
A:
You don't need jQuery for that, simple windows.location code will do it, e.g.:
windows.location.href = myUrl;
Nouveau
2009-07-30 15:42:40
+4
A:
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();
Ken Browning
2009-07-30 15:44:54
calling click() doesn't really navigate the page for you, does it? It will run the any attached click handlers, but it won't follow the href.
Frank Schwieterman
2010-10-06 23:39:29
click() generates a normal JavaScript click event so it should work, but you run into problems you try something like: $('#mydiv').click(function(){ $('#mylink').click() }); where #mylink is inside #mydiv -- this will result in an "endless" loop (really a "too much recursion" exception). If you want to navigate, it is safer to use: window.location.href = $('#mylink').attr("href");
MikeJ
2010-10-13 19:31:35
A:
I have run into a situation where I need to execute a URL change after a has completed.
I am pretty new to jquery so I am still learning it's capabilities.
I am sure someone out there has a better idea of how to do this.
$('#overlay').animate({left:"40%",top:"45%"},'20000').delay(40000).GETURL("http://myurl.com");
I would like to have an onComplete type of function that can fire once something has finished.
$('#overlay').animate({left:"40%",top:"45%"},'20000').onComplete(completedFunction);
Any help would be great
Eryx
2010-05-17 21:13:43
You need to ask your own question in StackOverflow, not just glom it on to the end of someone else's question. But for the record, jQuery animation functions all take a parameter which is a function to execute at the end of the animation. So you do it like this: $('#overlay').animate({left:"40%",top:"45%"},'20000',function(){ /*do stuff when animation complete*/ }); The jQuery function reference is online and makes stuff like this very clear -- suggest you check it out.
MikeJ
2010-10-13 19:36:35