Simulate the user clicking on a link
- by timkl
I want a link to be clicked when a key is pressed, I cooked up this jQuery:
$('form#form1').bind("keypress", function(e){
if(e.keycode == 13 || e.keyChar == 13 || e.which == 13){
$('.LoginBoxButton a').click();
}
});
It doesn't work, and I've read the following explaining why:
It's important to remember that
click() will not trigger the default
behavior on a link, even if nothing
else is preventing it. So you can't
use click() by itself to simulate the
user clicking on a link and being
taken to another url.
But how DO you simulate the user clicking on a link and being taken to another url?