Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-25-2005, 12:23 AM   PM User | #1
srk
New Coder

 
Join Date: May 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
srk is an unknown quantity at this point
Help! Click works but DoubleClick doesn't

Hi!

I have a piece of code for which I am trying to provide keyboard only navigation. In other words, I should be able to trigger click and double click events using spacebar(without using mouse). But when I hit the spacebar twice to trigger dblclick event, Iam getting the following error:

"Object doesn't support this property or method"

Please Help!
srk


My example code looks like this:

<HTML DIR=LTR>
<HEAD>
</HEAD>
<BODY>
<TABLE BORDER=1>
<TR>
<TD onkeydown="checkKey(event)"; onClick="alert('Click event')"; ondblClick="alert('dClick event')";><a href=#>Test1-a</a></TD>
<TD><a href=#>Test2-a</a></TD>
<TD><a href=#>Test3-a</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-b</a></TD>
<TD><a href=#>Test2-b</a></TD>
<TD><a href=#>Test3-b</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-c</a></TD>
<TD><a href=#>Test2-c</a></TD>
<TD><a href=#>Test3-c</a></TD>
</TR>
</TABLE>
<SCRIPT>
var thisEvt = null;
var thisEl= null;
var pushed = 0;
var clickid = null;
var ie4 = (navigator.appName.indexOf("Internet Explorer") !=-1) ? true: false;
function checkKey(evt){
if (!ie4) {
thisEvt = evt ;
thisEl=thisEvt.target ;
} else { thisEvt = window.event ; thisEl=thisEvt.srcElement ; }
if(thisEvt.keyCode==32){
pushed++;
if(clickid == null){
clickid = setTimeout("checkKey",200);
}else{
if (pushed == 2){
thisEl.dblclick();
pushed=0;
}
}
}
}
</SCRIPT>
</BODY>
</HTML>
srk is offline   Reply With Quote
Old 05-25-2005, 03:51 PM   PM User | #2
srk
New Coder

 
Join Date: May 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
srk is an unknown quantity at this point
Does anybody have any suggestions?
srk is offline   Reply With Quote
Old 05-25-2005, 06:29 PM   PM User | #3
JustABob
New to the CF scene

 
Join Date: May 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
JustABob is an unknown quantity at this point
Take this with a grain of salt as I am just getting into web programming...

Could it be that the program is trapping the single click event when you are trying to catch a double click? What happens if you try and write the code to just catch a single click? If it works try changing it to a double click event instead of a double just to make sure that the event is setup correct.

Hope it helps, and sorry I cant give you a better answer.
JustABob is offline   Reply With Quote
Old 05-25-2005, 06:58 PM   PM User | #4
srk
New Coder

 
Join Date: May 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
srk is an unknown quantity at this point
Thanks dor the response! It works just fine with click. It's just the doubleclick that's showing this error. I even tried defining just the double click with no luck.

Thank you,
srk
srk is offline   Reply With Quote
Old 05-26-2005, 05:04 AM   PM User | #5
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
http://www.codingforums.com/showthread.php?t=59651
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 05-26-2005, 03:54 PM   PM User | #6
srk
New Coder

 
Join Date: May 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
srk is an unknown quantity at this point
Thank you so much
srk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:34 PM.


Advertisement
Log in to turn off these ads.