try
{
}
catch(e)
{
}<body onerror="alert('error')">

解决方案 »

  1.   

    自动寻找错误,这样的函数是没有的了,不过也有折衷的方法。比如
    function test(sFun)
    {
         if(typeof(sFun)=="string")
         try {eval(sFun)} catch(e) {alert(e.)}
    }通过test这个函数作为接口运行其他函数。
      

  2.   

    <body onerror="yourFunction()">
    <script>
    function yourFunction()
      {alert()
       ……
       ……
      }
    </script>
      

  3.   

    <script>
    function catchError(m){
    try{
     eval(m).value='fason'
     }
     catch(e){
     alert(e.name+'\n'+e.description+'\n'+e.message+'\n'+e.number)
     }
    }
    catchError('fason')
    </script>
      

  4.   

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD><script>
    window.onerror = function(s,u,l){
    try
    {
    alert(u+"中\n\n"+l+"行\n\n发生了错误:"+s);
    }catch(e){}
    //to avoid IE handle it.
    event.cancelBubble = true;
    event.returnValue = true;
    return true;
    }
    </script>
    <BODY onclick="asdf">
    <!--BODY onclick="throw 'exception not catched'"-->
    <P>&nbsp;</P></BODY>
    </HTML>
      

  5.   

    好了,不过我还想知道用VBScript的方法,能说一下吗?
      

  6.   

    Sub ErrBreak(WatchValue,StopHere)
      'WatchValue:查看的变量值,Stop:是否中断在此函数处,而不管后面代码是否正确
        Response.write "<br><B style='background-color:#FF0000;Color:#FFFFFF;Font-si
    ze:12pt'>&nbsp;&nbsp;"&WatchValue&"&nbsp;&nbsp;<br>"
    if StopHere=true then Response.End      
      End Sub
    以上过程必须放在引用之前,例如:
    <!--#include file="conn.asp"-->
    <% 
      Sub ErrBreak(WatchValue,StopHere)'WatchValue:查看的变量值,Stop:是否中断在此函
    数处,而不管后面代码是否正确
        Response.write "<br><B style='background-color:#FF0000;Color:#FFFFFF;Font-si
    ze:12pt'>&nbsp;&nbsp;"&WatchValue&"&nbsp;&nbsp;<br>"
    if StopHere=true then Response.End      
      End Sub  ErrBreak Conn,true 
       '查看Conn的值,并在此处断点,VB调用函数或过程时不能使用(),
       '要使用括号必须是要获得返回值或Call来调用,即这里可以写成
       'Call ErrBreak(Conn,true)
       '如果这里的true改为false,这里就不执行中断。如果采用了中断,
       '就可以忽略后面的错误
    %>
      

  7.   

    try
    {
    ……
    }
    catch(e)
    {
    alert('error');
    }
      

  8.   

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD><script>
    window.onerror = function(s,u,l){
    try
    {
    alert(u+"中\n\n"+l+"行\n\n发生了错误:"+s);
    }catch(e){}
    //to avoid IE handle it.
    event.cancelBubble = true;
    event.returnValue = true;
    return true;
    }
    </script>
    <BODY onclick="asdf">
    <!--BODY onclick="throw 'exception not catched'"-->
    <P>&nbsp;</P></BODY>
    </HTML>
      

  9.   

    <script>
    try
    {
        new ActiveXObject("asd");
    }
    catch(e)
    {
        alert(e.message);
    }
    finally
    {
    }
    </script>
      

  10.   

    没人结贴try
    {
    }
    catch (e)
    {
      alert(e)
    }
      

  11.   

    <script>
    function catchError(m){
    try{
     eval(m).value='fason'
     }
     catch(e){
     alert(e.name+'\n'+e.description+'\n'+e.message+'\n'+e.number)
     }
    }
    catchError('fason')
    </script>还可以的