Your method seems really random. You should proceed differently.
Imagine the user has JS disabled, it's click won't be logged, you
should use a server side script that will log the click and redirect
the user to the desired file : href="dispatcher.php?file=program.exe"
If you don't have access to the server of can't modify the links, so
you should do like this, but keep in mind that's not the best way to
do this:

add a className to the link you want to log, say "log" and then make a
little DOM processing to change the link's behavior to log the click,
wait for the log action and then follow the link:

<a class="log" href="program.exe">download</a>
 <script type="text/javascript">
document.observe("dom:loaded", function(){
    e.observe("click", function(event){
        new Ajax.Request('/logger.php?action=1', {
           onSuccess: function(transport) {
On 11 août, 00:34, JoJo <> wrote:
> I'm collecting stats on user clicking behavior. In this example, I
> write an entry into the database whenever someone clicks a link that
> starts a download:
> <a href="program.exe" onclick="logClick()">download program</a>
> function logClick() {
>    new Ajax.Request(
>       '/logger.php?action=1'
>    );
> }
> This works great in Internet Explorer and Firefox. In Firefox, my
> Firebug highlights the request in red as if it's an error. Anyway, I
> see my database being updated, so I'm not too worried. What I'm
> worried about is this fails to work in Safari 4. The only way I can
> get it to work is:
> function logClick() {
>    new Ajax.Request(
>       '/logger.php?action=1', {
>          onSuccess: function(transport) {
>             alert(transport.responseText);
>          }
>       }
>    );
> }
> For some reason, this causes the database to be written to.
> Transport.responseText is blank for unknown reasons. How do I get this
> to work without the alert? The alert degrades the user experience.

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to