Someone told me, after using console.log() method, I would not need alert boxes and prepared some code:
<!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>
But it is not making the JavaScript stop running like a alert box would. It is also writing “Message” to the Firebug window.
-
How does it works on the client browser which doesn’t have Firebug?
-
Does it work on all browsers using the same syntax?
-
Was it made only for Web developing purposes?
It doesn’t work 🙂 Actually FireBug is not a requirement. Modern browsers such as Google Chrome for example have the
console.logmethod implemented and the output goes into their console. For legacy browsers it doesn’t work because this method is not defined.Yes, primarily for debugging.