[Javascript] Popup window stumper

Terrence Donnelly pag000 at mail.connect.more.net
Sat Dec 15 12:14:46 CST 2001


Could somebody tell me why the following code doesn't work.  This file
is included as a .js file in the head of the main document. A simple
click on a link calls function gologit.  This function correctly
makes a new window and displays the form and image in it, but clicking
on the "Log In" button does nothing at all.  I'm assuming I have
some sort of reference problem and/or confusion between the
parent and child windows, but I am stumped!

Thanks in advance.  

*******************************************************************************

// golofile.js - opens a login window
//  adapted from
//	The Javascript Source!! http://javascript.internet.com
var newWind
function gologit() {
	if (!newWind || newWind.closed) {
    		newWind = window.open("", "", "HEIGHT=300, WIDTH=250")
		if (!newWind.opener) {
			newWind.opener = window
		}
		var newContent = "<HTML><HEAD><TITLE>Grolier Online Log-In</TITLE>"

		newContent += "<SCRIPT LANGUAGE='JavaScript'>"
		newContent += "function TryItOut() {"
		newContent += "var theUser = newWind.document.logform.userbox.value;"
		newContent += "theUser = theUser.toLowerCase;"
		newContent += "var thePassword = newWind.document.logform.passbox.value;"
		newContent += "var theUserLength = theUser.length-1;"
		newContent += "var theUserFront = theUser.charAt(0);"
		newContent += "var theUserBack = theUser.charAt(theUserLength);"
		newContent += "var theFile = theUserFront + thePassword + theUserBack+
'.htm';"
		newContent += "alert(theFile);"
		newContent += "OpenIt(theFile);"
		newContent += "window.close(newWind.opener)"
		newContent += "}"

		newContent += "function OpenIt(theFile) {"
		newContent += "var root;"
		newContent += "if (opener.closed) {"
		newContent += "root = window.open('','');"
		newContent += "root.location.href = theFile;"
		newContent += "} else {"
		newContent += "opener.location.href = theFile"
		newContent += "}"
		newContent += "}"


		newContent += "</SCRIPT></HEAD>"

		newContent += "<BODY><CENTER><IMG SRC='grolog3.gif'><P>Please enter your
Username and Password<P>"
		newContent += "<FORM NAME='logform'>"
		newContent += "Login Name:&nbsp;<INPUT TYPE='text' NAME='userbox' VALUE=''
SIZE=10><br>"
		newContent += "Password:&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE='password'
NAME='passbox' VALUE='' SIZE=10><P>"
		newContent += "<INPUT TYPE='button' NAME='button' VALUE='Log In'
ONCLICK='newWind.document.TryItOut()'></FORM>"

		newContent += "</CENTER></BODY></HTML>"
		newWind.document.write(newContent)
		newWind.document.close()
	} else {
		newWind.focus()
	}
}

****************************************************************************
*******


-- Terry Donnelly




More information about the Javascript mailing list