var dwin = null; function debug(msg) { if ((dwin == null) || (dwin.closed)) { dwin = window.open("","debugconsole","scrollbars=yes,resizable=yes,height=100,width=300"); dwin.document.open("text/html", "replace"); } dwin.document.writeln('
'+msg); dwin.scrollTo(0,10000); dwin.focus(); // dwin.document.close(); // uncomment this if you want to see only last message , not all the previous messages }
add the above code in you page first. Try the following for example. for(var i=0;i<10;i++){ debug(i); //... you other statements here } this will open a new debug window and show/ouputs the value of i