How to display a confirmation dialog when clicking an <a> link?
问题 I want this link to have a JavaScript dialog that asks the user “ Are you sure? Y/N ”. <a href="delete.php?id=22">Link</a> If the user clicks “Yes”, the link should load, if “No” nothing will happen. I know how to do that in forms, using onclick running a function that returns true or false . But how do I do this with an <a> link? 回答1: Inline event handler In the most simple way, you can use the confirm() function in an inline onclick handler. <a href="delete.php?id=22" onclick="return