[thelist] forgotten win2000 logon

Richard Bennett richard.bennett at skynet.be
Thu Oct 4 04:59:48 CDT 2001


<tip type=JavaScript>
> in very complicated javascript applications, it would be useful if i could
> document.write(value) to another window... so that i could trace through
the
> program without bothersome alert boxes... anyone have ideas on this?

Try this:
(save as .js file, and include for debugging)

/*
   DynAPI Distribution
   Console Debugging Utility

   The DynAPI Distribution is distributed under the terms of the GNU LGPL
license.

   Requirements:
 none
*/

DynAPI.console={
 enabled : true,

 open : function() {
  if (!DynAPI.console.enabled) return;

DynAPI.console.consolewin=window.open('','DynAPIConsoleWindow','resizable=1,
scrollbars=1');
  DynAPI.console.consolewin.document.open('text/plain');
 },
 write : function(msg) {
  if (!DynAPI.console.enabled) return;
  if (!DynAPI.console.consolewin || DynAPI.console.consolewin.closed)
DynAPI.console.open();
  DynAPI.console.consolewin.document.writeln(msg);
  if (document.all) DynAPI.console.consolewin.scrollTo(0,
document.body.scrollHeight);
 },
 close : function() {
  if (DynAPI.console.consolewin) DynAPI.console.consolewin.close();
 },
 enable : function() {
  DynAPI.console.enabled=true;
 },
 disable : function() {
  DynAPI.console.enabled=false;
 },
 clear : function() {
  DynAPI.console.consolewin.document.open('text/plain');
 },
 dumpProperties : function(obj,hidemethods) {
  DynAPI.console.write('\nObject Properties\n-----------------')
  var s=[];
  for (var i in obj) {
   var l=s.length;
   if (typeof obj[i]=='function') {
    if (!hidemethods) s[l]=i+' = [method]';
    else continue;
   }
   else if (typeof obj[i]=='object') s[l]=i+' = '+obj[i];
   else s[l]=i+' ('+(typeof obj[i])+')'+' = '+obj[i];
  };
  s.sort();
  DynAPI.console.write(s.join('\n'));
 }
};


use like this:
DynAPI.console.write("hello")
(opens new window, or uses existing one if already open)

DynAPI.console.dumpProperties (document)
(gets all properties of the "document" object)

</tip>






More information about the thelist mailing list