"Chris" <.@> wrote in message news:<fm**************@newsfe6-gui.ntli.net>...
Thanks v much, works a treat
Glad to have helped out.
one oddity though
;-)
in IE 6 I had to alter the following
Error: Invalid argument.
---------------------------
I suspect you had a special character in your file name. I am using
the filename as the debug window name. Web browsers seem to take the
input file name and use the escape function on them. For instance,
the space character in a file name is converted to %20. The IE
version of window.opend doesn't accept a % as part of the debug window
name.
I have posted a new version of the file below. I filter out the % and
all the other special characters.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>javascript debug routines and tester</title>
<script type="text/javascript">
// Popup the debug window.
// You need to have enabled popup windows
function startDebug(debugMode) {
startDebug.debugMode = debugMode;
if (startDebug.debugMode == true) {
var debugWindowName =
document.URL.substr(document.URL.lastIndexOf("/")+1);
var thePosition = debugWindowName.indexOf(".");
if (thePosition > 0)
{ debugWindowName = debugWindowName.substr(0,thePosition); }
// Get rid of special characters because IE won't accept them
debugWindowName =
debugWindowName.match(/[a-zA-Z0-9]/g).join("");
try
{ startDebug.newWindow = window.open("",debugWindowName,
"scrollbars=yes,resizable=yes,width=700,height=500 "); }
catch(e)
{ debugWindowName = "debug";
startDebug.newWindow = window.open("",debugWindowName); }
startDebug.newWindow.document.writeln(
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional' +
'//EN">' + "<html><header><title>Window " + debugWindowName +
"</title></header><body><p>The debug information " +
"that follows was generated on " + Date() + "</p>");
}
}
// Example invocation & print: DumpProperties(document,'document');
function dumpProperties(obj, obj_name)
{
//Example invocation & print: DumpProperties(document,'document');
if (startDebug.debugMode == true )
{
debugOut('In DumpProperties. obj=' + obj_name);
for (var i in obj)
{
try
{ debugOut(obj_name + "." + i + " = " + obj[i]); }
catch(e)
{ debugOut("Error writing out structure. Was " +
e + " for " + i); }
}
}
}
function dumpPropertiesSorted(obj, obj_name)
{
var i;
var sorted = [ ];
var objCount = 0;
if (startDebug.debugMode == true )
{
debugOut('In DumpProperties. obj=' + obj_name);
for (i in obj)
{
sorted[objCount++] = i;
}
sorted.sort();
for ( i=0; i <sorted.length; i++)
{
try
{ debugOut(obj_name + "." + sorted[i] + " = " +
obj[sorted[i]]); }
catch(e)
{ debugOut("Error writing out structure. Was " +
i + " for " + sorted[i]); }
}
} // if we are debugging.
}
function debugOut(obj)
{
var theString = "" + obj;
if (startDebug.debugMode == true ) {
// Ordering of the replacement string is important
var theString = theString.replace(
/&/g, "&").replace(
/</g, "<").replace(
/>/g, ">");
// theString = theString.replace(/ /g, " ");
startDebug.newWindow.document.writeln(theString + "<br>");
}
}
</SCRIPT>
</head>
<body>
<script>
var test = {a:1, c:3, b:2};
var testBoolean = true;
startDebug(true);
dumpProperties(test,"test");
debugOut("display the test object in sorted form");
dumpPropertiesSorted(test,"test");
debugOut(testBoolean);
debugOut("<b>&<\/b>");
var myString = "abcDEF Ghi~123~ *&^ end";
debugOut("myString = " + myString +
" compressed: " +
escape(myString.match(/[a-zA-Z0-9]/g).join("") ) );
</script>
<p>Debug routines and testing.</p>
</body>
</html>