window.onerror不工作在铬 [英] window.onerror not working in chrome

查看:137
本文介绍了window.onerror不工作在铬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  window.onerror = function(){
警报(错误);
}

但我收到的是:

  notThere(); 
ReferenceError:notThere没有定义

我缺少什么?



浏览器:Chrome 26.0.1410.64 m



重现步骤:


  • 将代码添加到控制台。
  • 将notThere()添加到控制台


    window.onerror (请参阅jsfiddle - http://jsfiddle.net/PWSDF/ ),但显然不在控制台中 - 这是有道理的。


    I am trying to add an onerror event to my website.

    window.onerror = function() {
        alert("an error");
    }
    

    But all I receive is:

    notThere();
    ReferenceError: notThere is not defined
    

    What am I missing?

    Browser: Chrome 26.0.1410.64 m

    Steps to reproduce:

    • add the code to the console.
    • add notThere() to the console

    解决方案

    The window.onerror works in Chrome (see jsfiddle - http://jsfiddle.net/PWSDF/), but apparently not in the console - which makes some sense.

    这篇关于window.onerror不工作在铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆