473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Onclick handler firing multiple times when it shouldn't?

I have a web page that tracks clicks on certain hyperlinks. I am using
attachEvent() to attach to the document onClick handler, for IE browsers.
It works fine, except that for about 1 out of every 6 clicks, I get 2 to 4
click events for a single click. I know this because each time the
hyperlink is clicked, I write a record to a MySQL database. I write the
record to the database by setting the SRC property of an IFRAME on the page,
to a tracking script.

If I look at the database, for 1 out of every 6 clicks, I see 2 to 4 records
for the same click event (occassionally as many as 6 records). They are at
least 1 second and at most 7 seconds apart from each other.

What could be causing this and how can I fix it?

Thanks.
Jul 23 '05 #1
4 4599
On Sat, 30 Oct 2004 13:29:01 -0400, Robert Oschler
<no************@nospam.com> wrote:

[snip]
If I look at the database, for 1 out of every 6 clicks, I see 2 to 4
records for the same click event (occassionally as many as 6 records).
They are at least 1 second and at most 7 seconds apart from each other.
With that much separation, the most logical explanation is that someone's
clicking more than once (though I'm sure you've already ruled that out).
What could be causing this and how can I fix it?


Without seeing a demonstration, it's very difficult to say.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Robert Oschler wrote on 30 okt 2004 in comp.lang.javascript:
What could be causing this and how can I fix it?


A click-only-once should be simple:
var myClick = false;

function clicked(){
if (myClick) return false;
myClick = true;
do something()
return true;
}

............................

onclick = "clicked()"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #3

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
var myClick = false;

function clicked(){
if (myClick) return false;
myClick = true;
do something()
return true;
}

...........................

onclick = "clicked()"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)


Evertjan,

The problem with that approach is that more than one hyperlink is being
tracked. If I read it right, once any hyperlink was clicked, that function
would return false from then on.

Thanks.
Jul 23 '05 #4
Robert Oschler wrote on 30 okt 2004 in comp.lang.javascript:
Evertjan,

The problem with that approach is that more than one hyperlink is
being tracked. If I read it right, once any hyperlink was clicked,
that function would return false from then on.


Only the one single hyperlink were you put the string

onclick = "return clicked()"

in. [Do mind the return here!]

=================================

If you want to use it in different hyperlinks you could have different
myClick variables but I would suggest a timeout instead:

==================================

var myClick = false;

function clicked(){
if (myClick) return false;
myClick = true;
setTimeout('myClick = false;',200)
return true;
}
<a onclick="return clicked(xx)" src='xx.html'>xx</a>
<a onclick="return clicked(yy)" src='yy.html'>yy</a>
<a onclick="return clicked(zz)" src='zz.html'>zz</a>

NOT TESTED !!!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
2
by: schiefaw | last post by:
Hello, I created a custom event "Public Event ApprovalChangedEvent()" and set a function to catch it "Private Sub laset_ApprovalChangedEvent() Handles laset.ApprovalChangedEvent". The problem...
17
by: dan_williams | last post by:
I have the following test web page:- <html> <head><title>Test</title> <script language="Javascript"> <!-- function fnTR() { alert("TR"); }
2
by: =?Utf-8?B?Uml0YUc=?= | last post by:
I posted this question in the C# discussion group but am posting it here also since ASP is involved. I'm new to C# and need some help regarding an onClick event not firing. I have a data grid...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
8
by: Dan Rumney | last post by:
All, I have a web page (copied below) with 3 images on it of fixed dimensions. Each image has a map associated with it In the maps, there are a number of areas with an onClick handler...
21
by: brucedodds | last post by:
I have an Access 2003 form bound to a SQL Server table via ODBC. Often clicking a button on the form has the effect of requerying the form rather than firing the OnClick event. Does anyone have...
9
by: skultetc | last post by:
Hey all, I have a div displayed as a block with an onclick event that shows/ hides a different div underneath it. There is a link within the first div that takes the user to a different page. My...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.