如何在 Internet Explorer 中使用控制台日志记录? [英] How can I use console logging in Internet Explorer?

查看:25
本文介绍了如何在 Internet Explorer 中使用控制台日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有适用于 IE 的控制台记录器?我正在尝试将一堆测试/断言记录到控制台,但我无法在 IE 中执行此操作.

Is there a console logger for IE? I'm trying to log a bunch of tests/assertions to the console but I can't do this in IE.

推荐答案

您可以通过启动开发人员工具"(F12) 来访问 IE8 脚本控制台.单击脚本"选项卡,然后单击右侧的控制台".

You can access IE8 script console by launching the "Developer Tools" (F12). Click the "Script" tab, then click "Console" on the right.

在您的 JavaScript 代码中,您可以执行以下任一操作:

From within your JavaScript code, you can do any of the following:

<script type="text/javascript">
    console.log('some msg');
    console.info('information');
    console.warn('some warning');
    console.error('some error');
    console.assert(false, 'YOU FAIL');
</script>

此外,您可以通过调用 console.clear() 来清除控制台.

Also, you can clear the Console by calling console.clear().

注意:您似乎必须先启动开发者工具,然后刷新您的页面才能使其正常工作.

NOTE: It appears you must launch the Developer Tools first then refresh your page for this to work.

这篇关于如何在 Internet Explorer 中使用控制台日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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