日期:2014-05-16 浏览次数:20333 次
try { fo.bar(); } catch (e) { alert(e.name + ": " + e.message); } try { fo.bar(); } catch (e) { alert(e.name + ": " + e.message); }
try { throw new Error("Whoops!"); } catch (e) { alert(e.name + ": " + e.message);alert(e.name + ": " + e.description);//IE中两者结果一样,都是Whoops! }
try { fo.bar(); } catch (e) { if (e instanceof EvalError) { alert(e.name + ":" + e.message); } else if (e instanceof RangeError) { alert(e.name + ": " + e.message); } // etc } try { fo.bar(); } catch (e) { if (e instanceof EvalError) { alert(e.name + ":" + e.message); } else if (e instanceof RangeError) { alert(e.name + ": " + e.message); } // etc }
try { fo.bar(); } catch (e) { if (browserType != BROWSER_IE) { alert("name: " + e.name + "message: " + e.message + "lineNumber: " + e.lineNumber + "fileName: " + e.fileName + "stack: " + e.stack); } else { alert("name: " + e.name + "errorNumber: " + (e.number & 0xFFFF ) + "message: " + e.message"); } } try { fo.bar(); } catch (e) { if (browserType != BROWSER_IE) { alert("name: " + e.name + "message: " + e.message + "lineNumber: " + e.lineNumber + "fileName: " + e.fileName + "stack: " + e.stack); } else { alert("name: " + e.name + "errorNumber: " + (e.number & 0xFFFF ) + "message: " + e.message"); } }
try { throw new Date(); // 抛出当前时间对象 } catch (e) { alert(e.toLocaleString()); // 使用本地格式显示当前时间 }