File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Murach's Java Servlets and JSP this week in the Servlets 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!
 
 
subject: Suppress click on page once already clicked on image
 
Similar Threads
Ajax.InPlaceEditor and manual enterEditMode
problem as menu show behind of flash~ pls help
Java Script in AJAX response
Creating CSS class at runtime
Need Help with Jquery Selector logic