I'm using simple links for an admin panel but in case of user accidently clicks on link for user deletion, there should be a confirmation pop-up for avoding this.
Probably as you know a href tag's are not fully compatible with javascript. So, i have used span tag for "onclick" but that didn't went so well:
<script type="text/javascript">
function confirm_click()
{
return confirm("Are you sure ?");
}
</script>
Here is the html code for link:
<span onclick="confirm_click();"> <a title="Delete User" href="http://www.google.com"><i class="icon-remove-sign">DELETE</i></a></span>
Try...
<a title="Delete User" onclick="return confirm_click();" href="http://www.google.com"><i class="icon-remove-sign">DELETE</i></a>
...instead.
You need to return the value of your method, and returning false in an onclick event prevents the default behaviour (which in this case would be to navigate to the href).
Try
<a href='/path/to/action' onclick="return confirm('Are you sure ?')">Delete</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With