How to emulate an mousedown event using javascript? See, i got a link on a page smth like this:
<a class="boo" target="_blank" onmousedown="function_rc()" href="http://www.siteaddress.com" tabindex="2"></a>
and i have to dispatch onmousedown event in a programm way, after user makes some actions. for an example i tried this:
<html>
<head>
<script type="text/javascript">
function showChar()
{
alert('mouse down');
}
function fake()
{
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent ('mousedown', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getelementbyid('my_link').dispatchEvent(evt);
}
</script>
</head>
<body>
<a id="my_link" onmousedown="showChar()" >LLL</a>
<div id="alert" onclick="fake()">Click me!</div>
</body>
</html>
if i understand it correctly - when i click on div with id="alert" function start working, create an MouseEvent evt type=mousedown and dispatc this event on a with id="my_link". So after the evt is dispatched function showChar() should start. but it doesn't happen. who knows why and how to solve this situation?