HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 7th, 2000, 09:12 AM
vdschoor vdschoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: California
Posts: 43 vdschoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Is there a way to disable the onClick event?
The problem is this, I have an image inside a <TR>.
For the image an onclick event is defined, and for the row an onDblClick event.
I don't want the page to handle the onDblClick event when the image is (accidentally) doubleclicked..
Does anybody know a way of doing this?

Reply With Quote
  #2  
Old August 8th, 2000, 03:31 AM
rkmarcks rkmarcks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 81 rkmarcks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via AIM to rkmarcks
I've not seen a script for this, but the following should help.

Event.srcElement (IE4) and Event.target (NS4) specifies the object (Window, Document, Layer [for NS], or HTMLElement) on which the event occurred.

Event.type (JS 1.2) specifies the type of event that occured WITHOUT the prefix 'on'. ie: an 'onload' event would return 'load'

Window.captureEvents() and Window.releaseEvents() (NS only) do what they say, begin capture and end capture of events as specified by an event mask within the brackets (). The event mask, in your case, would be Event.DBLCLICK and Event.CLICK as defined by Event.TYPE (different from Event.type). They can be combined using a bitwise logical operator (ie: (Event.DBLCLICK & Event.CLICK)) rather than a boolean operator (ie: (Event.DBLCLICK && Event.CLICK)).

I think the only way to do something similar in IE is with Window.event. This is an IE only method and is used to describe the most recent event. I don't think it's quite the same as the above for NS. Since IE doesn't pass an event object as does NS, this is used by the event handlers to obtain information about the event.

Now the tricky part. Once you've captured and/or identified your event and the associated object, you probably want to 'cancel' it.

This is a bit easier in the IE DOM since it is a bubble up model vs Netscapes trickle down model. In IE, you should be able to use the cancelBubble property to stop the event from bubbling upward. Once you capture the event with:

e = window.event,

simply set the property to true with:

e.cancelBubble = true;

This stops propogation of that event in IE.

In Netscape, once you've captured the event, you must send it to a function. For example:

window.captureEvents(Event.DBLCLICK & Event.CLICK);

window.onDblClick = function(event){...};
window.onClick = funciton(event){...};

Just use some meaningless function like {x=1} or {;}. This stops event propogation right there.

You will probably have to set and clear the capturing of events as necessary. One more thing about NS. Since their DOM is a routedown model, if you capture the event, but determine it should be handled normally, you need to pass it to the Window.handleEvent() or Window.routeEvent() methods. In your case, since you would be 'cancelling' the event through the use of the functions I described above, I think Window.handleEvent() is the appropriate choice. This method will simply pass the event on to proceed as normal. You would use the routeEvent method if your function did something, but you wanted the event to continue propogation. Then the Window.routeEvent would be appropriate.

One note, the IE DOM model is considered more powerful than Netscapes and has been adopted as a standard for future DOM's. I don't know if the next release of NS will adopt this yet, but it is likely.

I've tried to properly capitalize everything above since these methods are case sensitive.

This is explained quite nicely in javascript:The definitive guide from www.oreilly.com. They have a three page script (pages 297-299 if you have access to the book) giving an example event monitor. IF you want, I could fax it to you. Would probably help immensely.

Sorry this is so long, but as you've probably gathered by now, your simple question doesn't have a real simple answer.

Russ

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by vdschoor:
Is there a way to disable the onClick event?
The problem is this, I have an image inside a <TR>.
For the image an onclick event is defined, and for the row an onDblClick event.
I don't want the page to handle the onDblClick event when the image is (accidentally) doubleclicked..
Does anybody know a way of doing this?
[/quote]


Reply With Quote
  #3  
Old August 9th, 2000, 12:46 PM
vdschoor vdschoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: California
Posts: 43 vdschoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Thanks Russ, but I've made a workaround.
Because it is an Intranet website and everybody is using IE I did it with a contextmenu.. looks pretty cool..
But I'm gonna try your solution too, for my own website.. to build some fancy stuff.

Iwan

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Disabling onClick events


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway