JavaScript中try…catch和异常处理
2009年6月5日
没有评论
在JavaScript可以使用try…catch来进行异常处理。例如:
try {
foo.bar();
} catch (e) {
alert(e.name + “ : “ + e.message);
}
try {
foo.bar();
} catch (e) {
alert(e.name + “ : “ + e.message);
} attachEvent方法,为某一事件附加其它的处理事件。(不支持Mozilla系列)
addEventListener方法 用于 Mozilla系列
举例:
document.getElementById(“btn”).onclick = method1;
document.getElementById(“btn”).onclick = method2;
document.getElementById(“btn”).onclick = method3;如果这样写,那么将会只有medhot3被执行
写成这样: 阅读全文…