P
Peter Michaux
Hi,
Below is an example of a synthetic click in Firefox. The browser does
not follow the link. Is that the just the way synthetic clicks work of
am I doing something wrong? I know the synthetic click occurs because
if I add an onclick attribute to the link the handler runs. Any ideas?
Thanks,
Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>synthetic click</title>
<script type="text/javascript">
window.onload = function() {
var el = document.getElementById('myLink');
var e = document.createEvent("MouseEvents");
e.initMouseEvent('click', // event type
true, // can bubble
true, // cancelable
window, // abstract view
0, // detail
0, // screenX
0, // screenY
0, // clientX
0, // clientY
false, // ctrl key
false, // alt key
false, // shift key
false, // meta key
0, // button
null); // related target
el.dispatchEvent(e);
}
</script>
</head>
<body>
<p><a id="myLink" href="http://www.yahoo.com">myLink</a></p>
</body>
</html>
Below is an example of a synthetic click in Firefox. The browser does
not follow the link. Is that the just the way synthetic clicks work of
am I doing something wrong? I know the synthetic click occurs because
if I add an onclick attribute to the link the handler runs. Any ideas?
Thanks,
Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>synthetic click</title>
<script type="text/javascript">
window.onload = function() {
var el = document.getElementById('myLink');
var e = document.createEvent("MouseEvents");
e.initMouseEvent('click', // event type
true, // can bubble
true, // cancelable
window, // abstract view
0, // detail
0, // screenX
0, // screenY
0, // clientX
0, // clientY
false, // ctrl key
false, // alt key
false, // shift key
false, // meta key
0, // button
null); // related target
el.dispatchEvent(e);
}
</script>
</head>
<body>
<p><a id="myLink" href="http://www.yahoo.com">myLink</a></p>
</body>
</html>