T
taras.di
Hi everyone,
I've just spent the last 2 hours banging me head against the desk
trying to figure this one out. I eventually figured out that sometimes
a form doesn't exist for the popup I'm specifying. I'm trying to write
a few functions that help me debug my script by writing variables to a
text area in a popup window. I came up with the following code:
var debug;
var debugWindow;
function setDebug(debugLevel)
{
debug = debugLevel;
}
function setupDebug(debugLevel, testURL)
{
if (debug != "none")
{
// set up a debug window
debugWindow =
window.open(testURL, "debugWindow", "menubar=no, status=no,"+
"width=400, height=300, toolbar=no, directories=no");
}
}
function writeDebug(message)
{
if (debug != "none")
{
var oldValue = debugWindow.document.forms[0].elements[0].value;
var newValue = oldValue + "\n" + message;
debugWindow.document.forms[0].elements[0].value = newValue;
}
}
setupDebug("debug","http://localhost:8080/debugArea.htm");
alert("FORMS: "+debugWindow.document.forms.length);
debugWindow.document.theForm.debugArea.value = "hello everyone";
debugArea.htm contains the following:
<HTML>
<BODY>
<FORM NAME ="theForm" METHOD =post>
<TEXTAREA ROWS ="15" COLS ="40" NAME ="debugArea">
</TEXTAREA>
</FORM>
</BODY>
</HTML>
The first time I load the script, the window pops up, and the alert
informs me the number of forms on the page is zero. Subsequent
refreshes (where the popup-window is already present) show that the
number of forms is 1.
Also, why doesn't 'hello everyone' ever popup.
Thanks
Taras
I've just spent the last 2 hours banging me head against the desk
trying to figure this one out. I eventually figured out that sometimes
a form doesn't exist for the popup I'm specifying. I'm trying to write
a few functions that help me debug my script by writing variables to a
text area in a popup window. I came up with the following code:
var debug;
var debugWindow;
function setDebug(debugLevel)
{
debug = debugLevel;
}
function setupDebug(debugLevel, testURL)
{
if (debug != "none")
{
// set up a debug window
debugWindow =
window.open(testURL, "debugWindow", "menubar=no, status=no,"+
"width=400, height=300, toolbar=no, directories=no");
}
}
function writeDebug(message)
{
if (debug != "none")
{
var oldValue = debugWindow.document.forms[0].elements[0].value;
var newValue = oldValue + "\n" + message;
debugWindow.document.forms[0].elements[0].value = newValue;
}
}
setupDebug("debug","http://localhost:8080/debugArea.htm");
alert("FORMS: "+debugWindow.document.forms.length);
debugWindow.document.theForm.debugArea.value = "hello everyone";
debugArea.htm contains the following:
<HTML>
<BODY>
<FORM NAME ="theForm" METHOD =post>
<TEXTAREA ROWS ="15" COLS ="40" NAME ="debugArea">
</TEXTAREA>
</FORM>
</BODY>
</HTML>
The first time I load the script, the window pops up, and the alert
informs me the number of forms on the page is zero. Subsequent
refreshes (where the popup-window is already present) show that the
number of forms is 1.
Also, why doesn't 'hello everyone' ever popup.
Thanks
Taras