JS: confirm() 函数将 OK 和 Cancel 的答案都设为 true
JS: confirm() function take both answers OK and Cancel as true
我正在尝试在 JS 脚本中使用 confirm()
函数来确认用户所做的重要的不可逆转的操作,例如通过重定向到相应的 link 来删除某些内容。但是我点击确定或取消都没有关系,它认为它是真实的并重定向。请帮助我知道我做错了什么。
function confirm_boy() {
if (confirm('are you really want to do what you are going to do?')) {
redirect('http://example/?dosomething');
}
}
您需要正确地包含 if 条件:
if (confirm('are you really want to do what you are going to do?')) {
console.log('ok')
}
else {
console.log('no')
}
您需要正确关闭 if
条件
function confirm_boy() {
if (confirm('are you really want to do what you are going to do?')) {
redirect('http://example/?dosomething');
}
}
我正在尝试在 JS 脚本中使用 confirm()
函数来确认用户所做的重要的不可逆转的操作,例如通过重定向到相应的 link 来删除某些内容。但是我点击确定或取消都没有关系,它认为它是真实的并重定向。请帮助我知道我做错了什么。
function confirm_boy() {
if (confirm('are you really want to do what you are going to do?')) {
redirect('http://example/?dosomething');
}
}
您需要正确地包含 if 条件:
if (confirm('are you really want to do what you are going to do?')) {
console.log('ok')
}
else {
console.log('no')
}
您需要正确关闭 if
条件
function confirm_boy() {
if (confirm('are you really want to do what you are going to do?')) {
redirect('http://example/?dosomething');
}
}