if(a.value==1 && b.value==2)
{
try{callFunc() }catch(e) {}
}
frm.submit();
Run Code Online (Sandbox Code Playgroud)
在里面function callFunc()
,我必须写什么才能完全停止执行?它不应该执行frm.submit();
function callFunc()
{
//stop execution here -- ensure it won't execute fm.submit()
}
Run Code Online (Sandbox Code Playgroud)
更好的一个是
function Abort()
{
throw new Error('This is not an error. This is just to abort javascript');
}
Run Code Online (Sandbox Code Playgroud)
比任何地方叫这个
try
{
for(var i=0;i<10;i++)
{
if(i==5)Abort();
}
} catch(e){}
Run Code Online (Sandbox Code Playgroud)
为你
function callFunc()
{
//stop execution here
Abort();
}
//code from where you are going to call
try
{
if(a.value==1 && b.value==2)
{
callFunc()
}
frm.submit();
}
catch(e) {}
Run Code Online (Sandbox Code Playgroud)