By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Confirmation message box on a link click?

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 18 Feb 2004 20:29:32 +0000, Craig <cr*******@hotmail.com> wrote:
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?


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.php"
onclick="return confirm('Are you sure?');">Delete</a>

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

P: n/a
Michael Winter wrote:
On Wed, 18 Feb 2004 20:29:32 +0000, Craig <cr*******@hotmail.com> wrote:
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?

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.php"
onclick="return confirm('Are you sure?');">Delete</a>

Mike


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!
Jul 20 '05 #3

P: n/a
<html><head><title>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="linkRef('http://www.yahoo.com' )">Yahoo.com</a>
</body>
</html>
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.