
location.replace doesn't seem to work
Hi Vidar, Thanks for your reply.
If I understand your code correctly, it looks for a password and shows it to
the user. The problem I'm having is that after the user sees this page once
I do not want it to appear again when he clicks the back button after the
user clicks either on the button on the page or on a back button in the
browser. The Javascript Bible indicated that the way to do this was to use
the location.replace command this would replace the current Url in the
history list on the client side with the url defined in the location.replace
command line, then this page would no longer show up when using back or
forward buttons.
Debugging the application, it looks like the function doReplace does not get
executed when the user either clicks on a back button in the page or on my
submit button. It looks like te onUnload event does not get triggered.
--
Robert Dufour, MCP, MCT
President SGI IMS Inc.
www.sgiims.com
Quote:
> Hi
> This will never work...
> Just submit the page to it self
> Bare bones example
> Also assuming you have a valid conn
> <%
> var err = "";
> if(Request.ServerVariables("REQUEST_METHOD") == "POST")
> {
> var rs = conn.Execute("SELECT ID FROM MyTable WHERE Login='" +
> Request.Form("Login") + "'' AND thePassword='" +
> Request.Form("thePassword") + "'");
> if(!rs.EOF)
> {
> Session("userID") = rs("ID").value;
> Response.Redirect("GoodUser.asp");
> }
> err ="Invalid username or password";
> }
> %>
> <html>
> <head>
> </head>
> <body>
> <%=err%><br>
> <form method="POST" action="THIS-PAGE.asp">
> Login<br>
> <input type="text" name="Login"></br>
> Password<br>
> <input type="password" name="thePassword"><br>
> <input type="submit" value="Submit">
> </form>
> </body>
> </html>
> --
> Best Regards
> Vidar Petursson - MVP
> http://www.icysoft.com
> No matter where you go there you are.
> -
> > Very simple code but I can't figure out why it won't work as advertised.
> > I can see that the location replace command executes in debug mode.
> > but after I go to another page and then click back i still have this
page
> > come up on the screen.
> > <%Response.Expires = 0%>
> > <html>
> > <head>
> > <SCRIPT Language="Javascript">
> > function doReplace() {
> > location.replace("d_ForgotPassword1.asp");
> > }
> > </SCRIPT>
> > </head>
> > <form NAME="d_senduserpassword" ACTION="d_getUserInfo.asp" Method="post"
> > onUnload="doReplace()">
> > <body>
> > <h1>Your password is.</h1>
> > <Font Size="2" color="blue"><B><% = Session("UserPassword")
%></B></FONT>
> > <p> </p>
> > <input TYPE="Image" src="images\btnLeft.gif" Value="Return entry screen"
> > WIDTH="45" HEIGHT="32" >
> > </Form>
> > </body>
> > </html>
> > --
> > Robert Dufour, MCP, MCT
> > President SGI IMS Inc.
> > www.sgiims.com