作用:和java类似,不过我觉得挺鸡肋的。哈哈,个人见解。。。
上代码:123.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="utf-8"> <script type="text/javascript"> function throwsNew(){ try{ throw new Error(10,"asdasdasd") ; }catch(e){ alert(e.message); alert(e.description) alert(e.number) alert(e.name) throw new Error(10,"asdasdasd") } } function throwsDate(){ try { throw new Date(); // 抛出当前时间对象 } catch (e) { alert(e.message); alert(e.description) alert(e.number) alert(e.name) alert(e.toLocaleString()); // 使用本地格式显示当前时间 } } </script> </head> <body> <a href="javascript:throwsNew()">抛异常</a> <a href="javascript:throwsDate()">抛异常</a> </body> </html>