Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a window using window.close

Status
Not open for further replies.

nospace52

Technical User
Jan 28, 2003
27
US
I'm putting together a database - one for employee's and on for supervisors - the database for the supervisors is to accessed thru a User and Password.
I have built the web pages and also built a users.mdb file.
Everything works fine.
The problem is that when the page2.asp loads I would like it to close so no one can see the URL.
This is for a internal web site.

Here is the code:
**PW1.asp**
<title>Input User and Password</title>
</head>

<body onload=&quot;window.close(&quot; bgcolor=&quot;#000000&quot;>

<form method=&quot;POST&quot; action=&quot;PAGE2.ASP&quot;>
 <font color=&quot;#FF0000&quot;><b><font face=&quot;Book Antiqua&quot; size=&quot;5&quot; color=&quot;#FF0000&quot;>User:</font></b>
</font><input name=&quot;USERNAME&quot; size=&quot;20&quot; style=&quot;font-family: Comic Sans MS; color: #0000FF; font-weight: bold&quot; type=&quot;password&quot;>
<font color=&quot;#FF0000&quot;><b><font face=&quot;Book Antiqua&quot; size=&quot;5&quot; color=&quot;#FF0000&quot;>Password:
</font></b></font><input name=&quot;PASSWORD&quot; type=&quot;password&quot; size=&quot;20&quot; style=&quot;font-family: Comic Sans MS; color: #0000FF&quot;>
<input name=&quot;SUBMIT&quot; type=&quot;SUBMIT&quot; value=&quot;LOGIN&quot;>
</form>

</body>

</html>


**page2.asp**
<title>[ ====== ]</title>
</head>

<body onload=&quot;window.close(&quot; &quot;)&quot; bgcolor=&quot;#C0C0C0&quot; style=&quot;text-transform: uppercase; font-family: AR Sans Serif; color: #FF0000; font-style: italic; font-weight: bold&quot;>

<%
Username = Request.Form(&quot;USERNAME&quot;)
Password = Request.Form(&quot;PASSWORD&quot;)
'Get username and password from previous page

SQL = &quot;SELECT * FROM Users Where Username='&quot; & Username & &quot;'&quot;
set adoConn = Server.CreateObject (&quot;ADODB.Connection&quot;)
set adoRS = Server.CreateObject (&quot;ADODB.RecordSet&quot;)
dbPath = Server.MapPath(&quot;users.mdb&quot;)
adoConn.Open &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=&quot; & dbPath
adoRS.Open SQL,adoConn
' OPen a DSN less connection to an access database and get the username and password for the record where username=username

If adoRS.EOF Then
'The username doesn't exist, do an error.
Response.Write &quot;Username Doesn't Exist!&quot;
Else
If Trim(Password) = Trim(adoRS(&quot;Password&quot;)) Then
'If the passwords match
Session(&quot;LoggedIn&quot;)=&quot;TRUE&quot;
'Set a session variable to true
%>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!-- Begin
function open_new_window(){
window.open(&quot;}
// End -->
</SCRIPT>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
window.location=&quot;JavaScript:eek:pen_new_window()&quot;
</SCRIPT>


<%
'Forward user to next page
Else
'Passwords don't match
Response.Write &quot;Password is incorrect&quot;
End If
End IF
set adoRS = Nothing
set adoConn = Nothing
%>


</body>

</html>
===========================================================

I have tried several ways to close the page2.asp when pages load and also by javascript. The javascript gives me a popup about the page closing but I would like to do it with out any user intervention.

Thanks and have a great day.

< I want to work in Theory - everything and everybody works in Theory !!>
 
Sorry if you haven't got any answers - the default action of post is to move to the next page, not leaving that window -Just like clicking on a link.

Have you figured out what is happening?

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top