[Javascript] Popup window stumper

Peter Brunone peter at brunone.com
Sat Dec 15 16:12:29 CST 2001


Terry,

	Do you have error messages turned on?  It seems like you should be getting
*something* if you're trying to call a function that can't be found.  Try
adding an alert to the beginning of the TryItOut function to see if it's
getting called; if it's not, I'd venture a guess that you still can't call
functions from other windows...

Cheers,

Peter

|-----Original Message-----
|From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
|Behalf Of Terrence Donnelly
|Sent: Saturday, December 15, 2001 12:15 PM
|To: javascript at LaTech.edu
|Subject: [Javascript] Popup window stumper
|
|
|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