“控制台”是InternetExplorer未定义的毛病

 admin  2020-03-31    评论

  将以下内容粘贴到JavaScript顶部(在应用控制台之前):

  (function() {

  // Union of Chrome, Firefox, IE, Opera, and Safari console methods

  var methods = ["assert", "cd", "clear", "count", "countReset",

  "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed",

  "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd",

  "select", "table", "time", "timeEnd", "timeStamp", "timeline",

  "timelineEnd", "trace", "warn"];

  var length = methods.length;

  var console = (window.console = window.console || {});

  var method;

  var noop = function() {};

  while (length--) {

  method = methods[length];

  // define undefined methods as noops to prevent errors

  if (!console[method])

  console[method] = noop;

  }})();

  函数闭包包装器是将变量范围限制为不定义任何变量。这防止了两个未定义的和未定义(和其他缺掉的方法)。

  编辑:我留心到HTML 5样板在js/plugins.js文件中应用相似的代码,假设您正在寻觅一种处理计划(很能够)是最新的。


上一篇:rplay 延迟测试
下一篇:没有了
版权信息
永久链接://a/mxzx/20200331-68.html
转载请注明转自》沙巴体育网址“控制台”是InternetExplorer未定义的毛病