aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Suppress click on page once already clicked on image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Suppress click on page once already clicked on image" Watch "Suppress click on page once already clicked on image" New topic
Author

Suppress click on page once already clicked on image

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Hi

I have an image on a page, on clicking which an event handler should be called.
The image lies inside a TD (table cell) which has its own click handler.



(spelling of onclikk changed for this message only)
On clicking the 'menu.png' , showMenu() function should be called and clicking anywhere else in the cell should call hideMenu() function.

But when I click on image the hideMenu() is called, not showMenu.

Can you please tell me what should I do? Is there any better approach (if this is wrong)? Any pointers will help.

Thanks
Satish Chilukuri
Ranch Hand

Joined: Jun 23, 2005
Posts: 266
When you have nested elements and they have the same event listeners, depending on how you add listeners, events will be fired in different order. See this page

My guess is showMenu() is getting called first and then immediately hideMenu() is getting called.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Look into Event Bubbling and how to cancel it.

Eric
Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Tons of thanks both of you! This was exactly what I was looking for!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suppress click on page once already clicked on image