Stopping double clicking with Perl CGI

mirod mirod at xmltwig.com
Thu May 22 14:53:35 BST 2008


Paul Makepeace wrote:
> On Thu, May 22, 2008 at 1:06 PM, David Cantrell <david at cantrell.org.uk> wrote:
>> On Thu, May 22, 2008 at 05:25:49PM +0800, Jesse Vincent wrote:
>>> On May 22, 2008, at 5:17 PM, Chris Jack wrote:
>>>> What is the best way of stopping a user double clicking a button in
>>>> a web page created using Perl CGI? ...
>>> A trivial javascript handler. Really.
>> Assuming for a moment that Chris cares because it's a problem and not
>> just for the sake of caring, then Javascript isn't the right solution,
>> as the user may not have it enabled.
> 
> He did also say,
> 
> """
> It seems to me that the logical way to do it would be to disable the
> button when it is pressed, but I haven't found an example of how to do
> that on the web yet.
> """
> 
> Which sounds a lot like JavaScript, the rest of the email
> notwithstanding. JavaScript is the right solution; you can't
> effectively do it with a trip to the server. And if the user disables
> JS, then ... pity that user.

No, you can't rely on the browser to send you only what you asked it to
send you. The no-script extension for Firefox for one will defeat your
best JS solutions.

The way to go is to first deal with that on the server side, which is
the only side that you have control over, and then, optionally, and just
to be nice to users, add the JS that will prevent cooperating browsers
to send the data twice.

Passing a unique id, as DC suggested earlier is the usual way I do this.

-- 
mirod


More information about the london.pm mailing list