Javascript 学习笔记 错误处理

 更新时间:2009年07月30日 21:41:04   作者:  
Javascript学习笔记:错误处理.
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

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();

相关文章

最新评论

?


http://www.vxiaotou.com