Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Prevent href double click

  • 21-12-2012 3:40pm
    #1
    Closed Accounts Posts: 6,075 ✭✭✭


    I have a href in a Jsp page that, when clicked, navigates the page to another page and calls a Java method. If you double click the href, the page navigates but the Java method is called twice. This is undesirable.

    Has anyone any suggestion on how to stop this? I've tried many internet suggestions but none have worked.

    Walrus


Comments

  • Registered Users, Registered Users 2 Posts: 1,144 ✭✭✭Ballyv24


    Use jquery to remove the href attribute of the link after the user clicks on it


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    JavaScript solutions I've used in the past involve replacing the link with a "Loading, please wait" graphic when it's clicked the first time.

    The ideal solution would be to detect double-clicks in the target page and abort one of them. Javascript solutions alone aren't ideal.


  • Closed Accounts Posts: 2,766 ✭✭✭juan.kerr


    You could also consider implementing a nonce (single use token) as well as the (client side) JavaScript. Some MVC frameworks have built in support for this.


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    Ballyv24 wrote: »
    Use jquery to remove the href attribute of the link after the user clicks on it

    I had thought of that but it's not as easy as that.

    Here is my code. I loop through a collection of products and displaying each record in a table. So each TR will be converted into a link, as follows:
    <tr id="x" data-href="${flowExecutionUrl}&_eventId=getProductDetails()">
    

    As you can see, I use a thing called data-href, which basically resolves to a href.


  • Registered Users, Registered Users 2 Posts: 27,370 ✭✭✭✭GreeBo


    for the client side have the href call a function passing the different params for each TR
    Within the function only allow single processing (if you are using ajax to call the backend for example) or just remove/hide/prevent all the other rows from being clickable

    but you should ideally couple this with a backend solution as advised above


  • Advertisement
Advertisement