X
Xu, Qian
Hello All,
I have some problem by simulating a link click using javascript.
The webpage uses a js-library named interface (jQuery like)
------------------------------
<a id="foo" href="#">Try try try</a>
$('#foo').click(function(){
$('ul',this.parentNode).BlindToggleVertically(500);
this.blur();
return false;
});
------------------------------
I tried first:
------------------------------
var elem = document.getElementById('foo');
elem.focus();
elem.click(); // does not work, and js becomes blocked
------------------------------
And then I tried:
------------------------------
var elem = document.getElementById('foo');
elem.focus();
if (elem.onclick || elem.onclick() !== false) {
alert('passed');
} else {
alert('failed'); // Program goes here :-(
}
------------------------------
Is it possible to simulate a link click?
I have an idea:
1. Retrieve the coordinate of the link.
2a. Simulate a mouse click at this position, or
2b. Simulate a keystroke "ENTER".
But I have no idea how to implement this. Can someone help me?
Thanks in advance ^^)
I have some problem by simulating a link click using javascript.
The webpage uses a js-library named interface (jQuery like)
------------------------------
<a id="foo" href="#">Try try try</a>
$('#foo').click(function(){
$('ul',this.parentNode).BlindToggleVertically(500);
this.blur();
return false;
});
------------------------------
I tried first:
------------------------------
var elem = document.getElementById('foo');
elem.focus();
elem.click(); // does not work, and js becomes blocked
------------------------------
And then I tried:
------------------------------
var elem = document.getElementById('foo');
elem.focus();
if (elem.onclick || elem.onclick() !== false) {
alert('passed');
} else {
alert('failed'); // Program goes here :-(
}
------------------------------
Is it possible to simulate a link click?
I have an idea:
1. Retrieve the coordinate of the link.
2a. Simulate a mouse click at this position, or
2b. Simulate a keystroke "ENTER".
But I have no idea how to implement this. Can someone help me?
Thanks in advance ^^)