Javascript 学习笔记 错误处理
更新时间:2009年07月30日 21:41:04 作者:
Javascript学习笔记:错误处理.
Java代码
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
利用firefox的firebug来调bug
引用
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(){
var a=0;
console.log("checkpoint 1");
a=a+1;
console.log("checkpoint 2");
a=a-1;
console.log("checkpoint 3");
a=a.toLowerCase();
console.log("checkpoint 4");
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
在IE中可以添加一个方法
引用
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
复制代码 代码如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
复制代码 代码如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(inVal){
try{
inVal=inVal.toUpperCase();
}catch(error){
alert("An exception has occurred.Error was:\n\n"+error.message);
}
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
利用firefox的firebug来调bug
引用
复制代码 代码如下:
<html>
<head>
<title>javascript</title>
<script type="text/javascript">
function test(){
var a=0;
console.log("checkpoint 1");
a=a+1;
console.log("checkpoint 2");
a=a-1;
console.log("checkpoint 3");
a=a.toLowerCase();
console.log("checkpoint 4");
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test(null);">
</body>
</html>
在IE中可以添加一个方法
引用
复制代码 代码如下:
function Console(){
this.log=function(inText){
alert(inText);
}
}
var console=new Console();
相关文章
Document:getElementsByName()使用方法及示例
Document:getElementsByName()想必大家对它并不陌生吧,主要是根据名称获取元素,下面是其具体的使用方法及范例,感兴趣的朋友不要错过2013-10-10JavaScript NaN和Infinity特殊值 [译]
本文要讲的是两个特殊值,NaN和Infinity,返回这两个值的操作通常都应该返回正常的数字2012-09-09
最新评论