Confirmation message box on a link click?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Craig

    #1

    Confirmation message box on a link click?

    Hi,

    I'm working on a PHP FTP client, but my testers have complained the delete file
    link is too easy to hit by mistake. Would it be possible/plausible to write a
    bit of javascript that pops up a confirmation when they click the link, that
    goes to a certain page if they click yes and does nothing if they click no?

    I have no idea if this is tough or not. Any help with this would be greatly
    appreciated.

    Regards,
    Craig
  • Michael Winter

    #2
    Re: Confirmation message box on a link click?

    On Wed, 18 Feb 2004 20:29:32 +0000, Craig <craig1000@hotm ail.com> wrote:
    [color=blue]
    > I'm working on a PHP FTP client, but my testers have complained the
    > delete file link is too easy to hit by mistake. Would it be
    > possible/plausible to write a bit of javascript that pops up a
    > confirmation when they click the link, that goes to a certain page if
    > they click yes and does nothing if they click no?[/color]

    This is fairly simple to do, but very unreliable: if JavaScript is
    disabled, there will be no confirmation option. The best thing to do would
    be to list on a new page all of the files and directories that will be
    deleted (or a summary of them), then get the user to confirm the deletion
    that way.

    If you still want to proceed with a JavaScript method:

    <a href="delete.ph p"
    onclick="return confirm('Are you sure?');">Delet e</a>

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • Craig

      #3
      Re: Confirmation message box on a link click?

      Michael Winter wrote:
      [color=blue]
      > On Wed, 18 Feb 2004 20:29:32 +0000, Craig <craig1000@hotm ail.com> wrote:
      >[color=green]
      >> I'm working on a PHP FTP client, but my testers have complained the
      >> delete file link is too easy to hit by mistake. Would it be
      >> possible/plausible to write a bit of javascript that pops up a
      >> confirmation when they click the link, that goes to a certain page if
      >> they click yes and does nothing if they click no?[/color]
      >
      >
      > This is fairly simple to do, but very unreliable: if JavaScript is
      > disabled, there will be no confirmation option. The best thing to do
      > would be to list on a new page all of the files and directories that
      > will be deleted (or a summary of them), then get the user to confirm the
      > deletion that way.
      >
      > If you still want to proceed with a JavaScript method:
      >
      > <a href="delete.ph p"
      > onclick="return confirm('Are you sure?');">Delet e</a>
      >
      > Mike
      >[/color]

      Yea I had a think and decided I do wanna go with the javascript. At the end of
      the day if a user deletes a file by mistake when the alert doesnt popup its
      still their own fault. The link is very clealy labelled, after all.

      So that works a treat. Thanks!

      Comment

      • JimMenees

        #4
        Re: Confirmation message box on a link click?

        <html><head><ti tle>href confirm</title>
        <script type="text/javascript">
        function linkRef(yurl ){
        var linkref = yurl;
        if(confirm("do you really want to go here?")){
        window.location .href=linkref;
        }
        }
        </script>
        </head>
        <body>
        <a href="#" onClick="linkRe f('http://www.yahoo.com' )">Yahoo.com </a>
        </body>
        </html>

        Comment

        Working...