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(){
  $$("a.log").each(function(e){
    e.observe("click", function(event){
        new Ajax.Request('/logger.php?action=1', {
           onSuccess: function(transport) {
              location.href=e.href;
           }
        };
        Event.stop(event);
      );
    });
  });
});
</script>
On 11 août, 00:34, JoJo <tokyot...@gmail.com> 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 & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to