javaScript中的异常
来源:互联网 发布:网络安全教育文章 编辑:程序博客网 时间:2024/06/16 07:08
一.javaScript中对异常的处理
<script>
function msg() {try {
aalert("nihao");
} catch (err) {
txt = "error";
}
}
</script>
</head>
<body>
<input type="button" value="view msg" onclick="msg()">
</body>
</html>
二.throw
<script>
function myf() {
try {
var x = document.getElementById("demo").value;
if (x == "")
throw "empty";
if (isNaN(x))
throw "not a num";
if (x > 10)
throw "big";
if (x < 5)
throw "small";
} catch (err) {
var y = document.getElementById("mess");
y.innerHTML = "error";
}
}
</script>
</head>
<body>
<p>请输入5-10之间的一个数</p>
<input type="text" id="demo">
<button type="button" onclick="myf()">click</button>
<p id="mess"></p>
</body>
</html>
0 0
- javascript 中的异常处理
- javascript中的异常处理
- javascript 中的捕获异常
- javascript 中的异常处理
- javascript中的异常处理
- javascript中的异常处理
- Javascript中的异常
- javascript中的异常处理
- JavaScript 中的异常处理
- javaScript中的异常
- Javascript中的异常处理
- JavaScript中的错误异常
- JavaScript中的错误异常
- JavaScript中的try...catch和异常处理
- JavaScript中的try...catch和异常处理
- C++、Java、JavaScript中的异常处理(Exception)
- javascript中的try catch异常捕获机制
- javascript 异常
- SQLi Labs Stacked Injections ( Lesson38 - Lesson53 )
- ajax
- (?:pattern) (?=pattern) (?!pattern)
- JQuery 的选择器可谓之强大无比
- 计算几何资料、
- javaScript中的异常
- iOS开发地图系列篇(一)
- 数据库基础语法--php基础最详细教程
- 字节对齐
- C++中的accumulate
- OpenCV 边缘检测
- 让你变懒的 Android Studio Live Templates
- 【2016年年中总结】——你变成了你喜欢的样子了吗?
- jdk6.0与7.0的区别