有人告诉我,使用 console.log() 方法后,我将不需要警告框并准备了一些代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>
function cool()
{console.log("Message");}</script>
</head>
<body onload="cool();">
</body>
</html>
但它不会像警告框那样让 JavaScript 停止运行。它还将“消息”写入 Firebug 窗口。
在没有 Firebug 的客户端浏览器上如何工作?
它是否适用于所有使用相同语法的浏览器?
它是否仅用于 Web 开发目的?
最佳答案
How it works on the Client browser which has not firebog.
它不起作用 :-) 实际上 FireBug 不是必需的。例如,Google Chrome 等现代浏览器实现了 console.log
方法,并将输出输入到它们的控制台。对于旧版浏览器,它不起作用,因为未定义此方法。
Was it made only for web developing purpose?
是的,主要用于调试。
关于javascript - JavaScript 中的控制台需要什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10562719/