当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript学习笔记:错误处理

Javascript
javascript手冊-r
javascript手冊-m&n
javascript手冊-p&q
javascript手冊-t
javascript手冊-e
javascript手冊总纲
javascript手冊-b
javascript手冊-a
JavaScript 实现动态增加、删除表单域
JavaScript:一个鼠标动态跟随文字特效的示例
如何使用可以接受输入的列表框
想让您的桌面文字背景透明吗?
淡出淡入 Script
OpenGL Step by Step
看看你的状态栏有什么在动??
自定义 IE 鼠标右键弹出式
抓住网页恶意代码的"黑手"
一个javascript脚本写的俄罗斯方块
检查指定Text输入框的值是否是数值型数据
将sTableName表中的sFieldNameArr数组字段数据根据条件sWhere加载到selName

Javascript学习笔记:错误处理


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 56 ::
收藏到网摘: n/a

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