2009-02-06 62 views
1

有谁知道如何得到下面的报告javascript错误? (任何浏览器)YUI CustomEvent没有错误报告


<head> 
    <title></title> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js"> 
    </script> 
    <script type="text/javascript"> 

     ObjWithEvent = { 
      testEvent: new YAHOO.util.CustomEvent("testEvent") 
     }; 

     ObjSubscriber = { 
      handleTestEvent: function(){ 
       alert('the next line will not show up in the error console'); 
       not_a_valid_function_bro(); 
      } 
     }; 

     ObjWithEvent.testEvent.subscribe(ObjSubscriber.handleTestEvent); 
     ObjWithEvent.testEvent.fire(); 
    </script> 
</head> 
<body> 
</body> 

回答

10

有史以来..... YAHOO.util.Event.throwErrors设置为默认为false最坏的选择默认设置可能,所以如果你想要查看错误:

YAHOO.util.Event.throwErrors = true;

+2

毫无疑问是最令人沮丧的默认设置之一,尤其是如果您是JavaScript新手。 – 2010-11-16 20:10:08

相关问题