简体   繁体   English

Windows Vista Internet Explorer 9 console.logs

[英]Windows vista Internet Explorer 9 console.logs

I am having an issue with IE9 on vista. 我在Vista上遇到IE9的问题。 I had console.logs/errors/warns being used, but that seemed to break IE9 (found many articles of why) if I hadnt already opened the developer tools. 我曾经使用console.logs / errors / warns,但是如果我还没有打开开发人员工具,那似乎就破坏了IE9(找到了很多原因)。 so I applied the following to make console.log available to the ie9 所以我应用了以下命令使console.log对ie9可用

window.console.log = function(){}
window.console.error = function(){}
window.console.warn = function(){}
window.console.info = function(){}
window.console.debug = function(){}

So that seemed to load past where it did before. 因此,这似乎超出了以前的范围。 I also have encountered an issue in the past where if you have a trailing comma on an object definition than IE would break aswell. 过去我也遇到过一个问题,如果您在对象定义上使用逗号结尾,则IE也会中断。

example: 例:

a = {a:1, b:2, c:3,}

I am using CoffeesScript so I am assuming that this isnt an issue. 我正在使用CoffeesScript所以我假设这不是问题。

So my problem is that there seems to be a javascript method breaking internet explorer. 所以我的问题是,似乎有一个JavaScript方法破坏了Internet Explorer。 But only when the developer tools hasnt been opened. 但仅当开发人员工具尚未打开时。 But I cannot view the error without opening the developer tools. 但是,如果不打开开发人员工具,我将无法查看错误。

Can I make my javascript errors available on windows vista IE9 without initialising the developer console 我可以在不初始化开发人员控制台的情况下使Windows Vista IE9上出现JavaScript错误吗?

Thanks 谢谢

window.console itself is not defined in IE when the debugger is not running so you need to add this first line for IE: 当调试器未运行时,IE中未定义window.console本身,因此您需要为IE添加第一行:

window.console = {};
window.console.log = function(){}
window.console.error = function(){}
window.console.warn = function(){}
window.console.info = function(){}
window.console.debug = function(){}

Personally, I'd suggest this which will take care of all browsers: 就个人而言,我建议您使用所有浏览器:

if (!window.console) {
    window.console = {};
    window.console.log = function(){}
    window.console.error = function(){}
    window.console.warn = function(){}
    window.console.info = function(){}
    window.console.debug = function(){}
}

If this doesn't help with the particular issue that's afflicting you, then you can try to install your own exception handlers around possible areas where the problem is and attempt to catch the exception yourself. 如果这不能解决困扰您的特定问题,那么您可以尝试在可能出现问题的区域周围安装自己的异常处理程序,并尝试自己捕获异常。 You may have to put details about the exception onto the screen (append them to a visible div or put them in an alert) if you can't use the debugger. 如果您无法使用调试器,则可能必须在屏幕上放置有关异常的详细信息(将其添加到可见的div或置于警报中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM