我在使用 jQuery 设置的特定事件处理程序中发生了错误,并且代码只是中断而没有显示任何错误。当我过去在 YUI 中编写类似的代码时,我会设置 YAHOO.util.Event.throwErrors = true;在我的开发中。 version 并告诉 YUI 的事件处理程序抛出错误。我找不到类似的东西,难道只是我瞎了没有看到它?
Thanks!
这是一个例子...
<html>
<head>
<title>jQuery Events</title>
</head>
<script src="https://www.google.com/jsapi"></script>
<script>
google.load('jquery', '1.3.2');
</script>
<body>
<p>click me</p>
<script type="text/javascript">
$(document).ready(function() {
$("p").click(function() {
console.log('How to display an error here similar to the native onclick ?');
qaz;
console.log('this line is not executed because of the error, but the error is not reported. Is there a way to have jQuery report those errors ?');
});
});
</script>
</body>
</html>
我非常确定 jQuery 不会为你吞下错误,所以你肯定应该看到来自 undefined 的错误qaz
.
运行更新后的页面,我仍然看到console.log
以及未定义的错误qaz
在萤火虫中。打开正常的浏览器错误控制台,我还看到qaz is not defined (...temp.html - Line: 15)
那里也有消息。在 IE 中,我当然得到"console" is undefined
,但这只是表明错误也在那里发生(因为没有控制台)。假设您正在运行完全相同的 html/js 片段,显然还有其他一些变量在起作用,这会给您带来问题。
您运行的是哪个版本的 Firebug?我在 1.4.x 版本中调试 javascript 等时遇到了各种随机问题,但 1.5.0 似乎更加一致和稳定。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)