IE8中的Console.log

我有下面的代码,经过测试,在IE8中不起作用。 我在IE11和Chrome上运行它运行得很好。 我已经调试了IE8中的代码,它指向“console.log作为问题区域。最有趣的是,当我开始在IE8中调试JS时 – 它踢它并且这段代码开始工作。然后再次,在离开调试时,关闭并重新打开文件 – 同样的故事,直到你进入调试)))。

jQuery(function () { $('.Response input[type=radio]').change(function () { console.log(this.value) if (this.value == 'Y' || this.value == 'NA' || this.value == 'NS') { $(this).closest('.ui-accordion-content').prev().css("background", "#AADDB2"); } else if (this.value == 'N') { $(this).closest('.ui-accordion-content').prev().css("background", "#FFC5C5"); } }); }); 

有任何想法吗? 会很感激你的帮助。 PS。 不幸的是,用户类型“必须”使用IE8并且升级不是一种选择(((。提前谢谢)))

你可以在console.log上防止ie8错误

 if (!window.console){ console = {log: function() {}} }; 

如果console不存在,您可以添加一些安全代码来定义console

 if (typeof console === "undefined" || typeof console.log === "undefined") { console.log = function(log_message) { alert(log_message); }; }