IE8 中的 console.log 发生了什么? [英] What happened to console.log in IE8?

查看:25
本文介绍了IE8 中的 console.log 发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这篇文章测试版,但它不在发布中?

解决方案

更适合后备的是:

<前><代码>var alertFallback = true;if (typeof console === "undefined" || typeof console.log === "undefined") {控制台 = {};如果(警报回退){控制台日志 = 功能(味精){警报(味精);};} 别的 {console.log = function() {};}}

According to this post it was in the beta, but it's not in the release?

解决方案

Even better for fallback is this:


   var alertFallback = true;
   if (typeof console === "undefined" || typeof console.log === "undefined") {
     console = {};
     if (alertFallback) {
         console.log = function(msg) {
              alert(msg);
         };
     } else {
         console.log = function() {};
     }
   }

这篇关于IE8 中的 console.log 发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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