发现控制台是否可用 [英] finding out if console is available

查看:116
本文介绍了发现控制台是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果控制台对象可用,我如何找到 javascript

I was wondering, how can i find out with javascript if the console object is available?

我有问题,如果我忘记删除一个调试输出,如 console.log('sthg')我在几个浏览器中收到错误,如果没有firebug或类似的活动。

i have the problem that if i forget to remove a debug output like console.log('sthg') i get errors in several browsers, if there is no firebug, or similar, active.

感谢您的帮助

在该问题旁边,我对所有关于控制台对象的信息感兴趣。有人有文档链接吗?是标准吗等等...

推荐答案

检查属性是否存在作为窗口的成员

Check the property exists as a member of window:

if (window.console) {
}




在这个问题旁边,我对有关控制台对象的所有信息感兴趣。有人有文档链接吗?是标准吗等等...

查看控制台API的Firebug文档; Chrome和Safari实现了大部分(但不是全部)列出的方法。没有标准定义控制台应该是什么,所以您需要测试每个浏览器,看看它是否支持该功能。

Check out the Firebug documentation for the Console API; Chrome and Safari implement most, but not all, of the methods listed there. There's no standard defining what should be in the console, so you'll need to test each browser to see if it supports the feature.

这篇关于发现控制台是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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