document.images['imgname'].click()?

M

Mad Joe

This piece of code is working in IE, but not in my Firefox.
The last link should simulate onclick event on the upper image.
Can you suggest me how to make it crossbrowser compatible, please?

....
<a href="http://www.google.com"><img src="img.jpg" id="mypic"
name="mypic"></a><br />
<a href="#something"
onclick="alert(document.images['mypic'].src)">Browser compatibility
check!</a><br />
<a href="#something" onclick="document.images['mypic'].click();">Onclick
event simulation on the upper image!</a>
....

Thanks!
Joe
 
V

VK

Mad said:
This piece of code is working in IE, but not in my Firefox.
The last link should simulate onclick event on the upper image.
Can you suggest me how to make it crossbrowser compatible, please?

Artificial events are not propagated by hierarchy, they are applied
directly to the element they are called for and they stop at this
point.

Also in application to clicks a good part of "common annoyance" and
"interface stealing" protection is based on distinguish between
"physical click" (made by mouse) and "programmed click" (made by
script), so I don't expect it will work as you possibly want even if
you apply it directly to the link itself. You may try though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top