Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  40] [ 1]  / answers: 1 / hits: 46367  / 12 Years ago, tue, november 27, 2012, 12:00:00

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>

More From » html

 Answers
28

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).


[#81780] Sunday, November 25, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eden

Total Points: 730
Total Questions: 117
Total Answers: 117

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;