我需要一個函數,當捕獲錯誤時停止執行javascript。舉例如下:停止javascript執行時捕捉錯誤
function AA()
{
try{
executeScript();
}catch(e){
//stop execute javascript
}
}
function executeScript()
{
throw 'error';
}
function BB()
{
//some script
}
AA();
BB(); //don't execute when error happening
有人知道該怎麼做嗎?感謝幫助。
呃......「return」怎麼樣? – Teemu
如果這些答案不能滿足您的需求,請您添加更多信息... – Beygi