M
Mike Gratee
Is it possible to use JavaScript to cause the browser to click a link on a
page and have the browser act exactly like the user had clicked on the link
directly?
In other words, I need to programmatically issue a JavaScript statement
which causes the browser to act just like the user clicked on a link in my
page. And if that link has an onClick JS event defined, I'd want that
onClick event to execute too, exactly the same as if the user actually
clicked on the link.
I know you may be thinking that I should just call the onClick event for the
link directly rather than trying to simulate a click using JavaScript.
However this is not sufficient. In my case I need to use JS to cause the
browser to click a link just like the user had clicked it, have any
corresponding events that may be defined fire (such as onClick), and then
have the browser follow the href for the link to its appropriate
target/page. Think of it as a macro-like operation I am trying to do
whereby I am simulating an action of and end user that is clicking a link.
Can someone let me know if this is possible, and if so, how? I need it to
work with IE 5 and higher, and the later versions of Netscape/Opera/Mozilla
if possible.
I'm thinking that someone I may be able to access the properties of an href
tag programmatically and call a method on it to simulate a real click. Any
code samples or snippets would be MUCH appreciated.
Thanks!!
** Mike
page and have the browser act exactly like the user had clicked on the link
directly?
In other words, I need to programmatically issue a JavaScript statement
which causes the browser to act just like the user clicked on a link in my
page. And if that link has an onClick JS event defined, I'd want that
onClick event to execute too, exactly the same as if the user actually
clicked on the link.
I know you may be thinking that I should just call the onClick event for the
link directly rather than trying to simulate a click using JavaScript.
However this is not sufficient. In my case I need to use JS to cause the
browser to click a link just like the user had clicked it, have any
corresponding events that may be defined fire (such as onClick), and then
have the browser follow the href for the link to its appropriate
target/page. Think of it as a macro-like operation I am trying to do
whereby I am simulating an action of and end user that is clicking a link.
Can someone let me know if this is possible, and if so, how? I need it to
work with IE 5 and higher, and the later versions of Netscape/Opera/Mozilla
if possible.
I'm thinking that someone I may be able to access the properties of an href
tag programmatically and call a method on it to simulate a real click. Any
code samples or snippets would be MUCH appreciated.
Thanks!!
** Mike