我遇到如下情况。事情发生了,用户需要决定是否要继续。如果他不这样做,则代码将停止执行。如果他这样做,它将继续。
但是,我不想让相同的代码两次出现,而是希望当顶部的if语句返回false时,也执行该部分(很多代码)。
在VB中,我会使用GOTO,但是Javascript中没有等效项。
if(true){
var r = confirm("although this and that... do you still want to continue?");
if (r == false) {
break;
} else {
a lot of code
}
}
有任何想法吗?
发挥作用
function confirmPop(){
if(true){
var r = confirm("although this and that... do you still want to continue?");
if (r == false) {
break;
} else {
a lot of code
}
}
}
然后打电话
confirmPop();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句