我正在寻找用于确定/取消功能的简单 JavaScript。就像 Hotmail 一样,当要删除电子邮件时,它会提示您是继续还是取消。
我当前的代码只会自动运行两个 JavaScript。因此,现在我正在寻找可以暂停 JavaScript 并仅在 onclick 不执行任何操作时才激活它的代码。
<script type="text/javascript">
var first = confirm("We are sending you to an external site, do you wish to proceed? ")
if (first)
window.location = "http://www.google.com"
else
window.close;
var second = confirm("We are sending you to an external site, do you wish to proceed? ")
if (second)
window.location = "http://www.yahoo.com"
else
window.close;
</script>
<a href="" onclick="javascript:first" title="opens the external website in a new window">Google</a>
<a href="" onclick="javascript:second" title="opens the external website in a new window">Yahoo</a>