Menu
Feb 10, 2011

Development tips: JavaScript debugger statement

According with the MDC the debugger statement was introduced in ECMA-262, Edition 5

Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.

This statement is very handy when trying to debug eval’ed code like the View definition in Openbravo 3.0. It seems the only way to have an entry point to the JavaScript program running in the browser.

I’ve tested this statement in Internet Explorer 8, Firefox 4b10 and Chrome 9. And works when you have a debugger running. Note: In Firefox you need Firebug available for that page.

<html>
<head>
</head>
<body>
<script type="text/javascript">
function f() {
 var message = 'hello world';
 debugger;
 if(typeof window.console !== 'undefined') {
   console.log(message);
 }
 else {
   alert(message);
 }
}
f();
</script>
</body>
</html>

Here you have some screenshots:

Internet Explorer
Internet Explorer - JS debugger

Firefox
Firefox/Firebug - JS debugger

Chromium/Chrome
Chrome/Chromium - JS debugger

Categories: Other | Leave a comment

Leave a Comment

(required)

 

Legal Note: Your comment is subject to our privacy policy and website terms.

© 2008-2015 Openbravo, S.L.U. All rights reserved | Privacy Policy | Website Terms