javascript popup alert on link click
问题 I need a javascript 'OK'/'Cancel' alert once I click on a link. I have the alert code: <script type="text/javascript"> <!-- var answer = confirm ("Please click on OK to continue.") if (!answer) window.location="http://www.continue.com" // --> </script> But how do I make it so this only runs when clicking a certain link? 回答1: just make it function, <script type="text/javascript"> function AlertIt() { var answer = confirm ("Please click on OK to continue.") if (answer) window.location="http:/