YUI CustomEvent no errors being reported

橙三吉。 提交于 2019-12-21 06:58:01

问题


Does anyone know how to get the below to report a javascript error? (any browser)


<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>


回答1:


Possibly one of the worst chosen default settings ever..... YAHOO.util.Event.throwErrors is set to false by default, so if you want to see errors:

YAHOO.util.Event.throwErrors = true;



来源:https://stackoverflow.com/questions/521521/yui-customevent-no-errors-being-reported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!