调整弹出警报
Adjusting a popup alert
我需要调整这个弹出警告,这样如果用户点击 "cancel" 就会让他们停留在同一页面上(而不是从他们点击的 link 重定向到页面在)。这是我正在处理的内容:
function myFunction() {
var txt;
if (confirm("Are you sure you want to move on? Your work on this passage
will be lost.")) {
} else {
}
你能给我一些建议吗?谢谢!
试试这个:
function myFunction() {
var txt;
if (confirm("Are you sure you want to move on? Your work on this passage
will be lost.")) {
} else {
window.history.back();
}
这样它就停留在当前页面,除非用户点击确定。
function myFunction() {
var redirect_url = 'http://whatever.com';
if (window.confirm("Are you sure you want to move on? Your work on this passage will be lost.")) {
window.location(redirect_url);
}
}
我需要调整这个弹出警告,这样如果用户点击 "cancel" 就会让他们停留在同一页面上(而不是从他们点击的 link 重定向到页面在)。这是我正在处理的内容:
function myFunction() {
var txt;
if (confirm("Are you sure you want to move on? Your work on this passage
will be lost.")) {
} else {
}
你能给我一些建议吗?谢谢!
试试这个:
function myFunction() {
var txt;
if (confirm("Are you sure you want to move on? Your work on this passage
will be lost.")) {
} else {
window.history.back();
}
这样它就停留在当前页面,除非用户点击确定。
function myFunction() {
var redirect_url = 'http://whatever.com';
if (window.confirm("Are you sure you want to move on? Your work on this passage will be lost.")) {
window.location(redirect_url);
}
}