|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to redirect after ALERT.I am using this code to raise an Alert and it works fine. What I'd like to do is to redirect the user to the previous page based on this script: .... OTHER CODE HERE If NOT rsAccounts.EOF Then rsAccounts.close strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" strMSG = strMsg & "You have already made your selections!\n\n" strMSG = strMsg & "Email the adminsitrator to have them deleted!" Response.Write("<" & "script>alert('" & strMSG & "');" & "<" & "/script>") End if%> I've tried using location.href and response.redirect to no avail. I need to do this right after Response.Write. Could someone point me in the right direction please? Thanks to all Sorry folks, my bad. I said the PREVIOUS Page, but it could be any page.
Sorry about that. Alexis. "Alexis Faren" <alexis.fe***@mentorits.com> wrote in message news:uptEdI4uJHA.5684@TK2MSFTNGP03.phx.gbl... Good Easter to all.I am using this code to raise an Alert and it works fine. What I'd like to do is to redirect the user to the previous page based on this script: ... OTHER CODE HERE If NOT rsAccounts.EOF Then rsAccounts.close strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" strMSG = strMsg & "You have already made your selections!\n\n" strMSG = strMsg & "Email the adminsitrator to have them deleted!" Response.Write("<" & "script>alert('" & strMSG & "');" & "<" & "/script>") End if%> I've tried using location.href and response.redirect to no avail. I need to do this right after Response.Write. Could someone point me in the right direction please? Thanks to all Server-side code has no concept of document, or window or location, etc.
HTTP is a stateless protocol so the previous page typically is not known. The only objects available to server-side code are Request, Response, Server, Session and Application, along with COM objects that are used via CreateObject. You really need to make an effort to keep this in mind. It's one of the biggest hurdles for novice web developers. However, if the browser bothers to populate it, the HTTP_REFERER servervariable will contain the url of the page that submitted the request: submitter = Request.ServerVariables("HTTP_REFERER") I think all modern browsers will populate this variable (barring security settings that the user may have set) so this should be OK, However, an alternative that might be a little more robust is to add the client-side call to the history object to your response.write that raises the alert: Response.Write "<" & "script>alert('" & strMSG & "');" & _ "window.history.back();" & "<" & "/script>" By the way, the above can be simplified by switching out of the server-side Response.End code block: <% ... OTHER CODE HERE If NOT rsAccounts.EOF Then rsAccounts.close strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" strMSG = strMsg & "You have already made your selections!\n\n" strMSG = strMsg & "Email the adminsitrator to have them deleted!" %> <script type="text/javascript"> alert('<%= strMSG %>'); window.history.back(); </script> <% Response.End End If ..%> Alexis Faren wrote: Show quoteHide quote > Sorry folks, my bad. I said the PREVIOUS Page, but it could be any > page. > > Sorry about that. > > Alexis. > "Alexis Faren" <alexis.fe***@mentorits.com> wrote in message > news:uptEdI4uJHA.5684@TK2MSFTNGP03.phx.gbl... > Good Easter to all. > > I am using this code to raise an Alert and it works fine. What I'd > like to do is to redirect the user to the previous page based on this > script: > > ... OTHER CODE HERE > > If NOT rsAccounts.EOF Then > rsAccounts.close > > strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" > strMSG = strMsg & "You have already made your selections!\n\n" > strMSG = strMsg & "Email the adminsitrator to have them > deleted!" > > Response.Write("<" & "script>alert('" & strMSG & "');" & "<" & > "/script>") > > End if > %> > > I've tried using location.href and response.redirect to no avail. > > I need to do this right after Response.Write. > > Could someone point me in the right direction please? > > Thanks to all -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" Actually I reviewed my ALERT code and thought "What the Heck...".
So I just did this: Response.Write("<" & "script>location.href=('" & redir & "');") Response.Write("<" & "/script>") Works like a hot darn. Also, I did try switching from server block to client bock, but it wouldn't work consistently in FF (IE seemed OK). So I needed more complete solution. I should have posted that little detail as well - my bad. Thanks Bob... btw: I've gotten a lot from this site, everyone here does an excellent job in helping novices and others. KOODOS!!! Show quoteHide quote "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message news:e10ppb4uJHA.1240@TK2MSFTNGP02.phx.gbl... > Server-side code has no concept of document, or window or location, etc. > HTTP is a stateless protocol so the previous page typically is not known. > The only objects available to server-side code are Request, Response, > Server, Session and Application, along with COM objects that are used via > CreateObject. > > You really need to make an effort to keep this in mind. It's one of the > biggest hurdles for novice web developers. > > However, if the browser bothers to populate it, the HTTP_REFERER > servervariable will contain the url of the page that submitted the > request: > > submitter = Request.ServerVariables("HTTP_REFERER") > > I think all modern browsers will populate this variable (barring security > settings that the user may have set) so this should be OK, However, an > alternative that might be a little more robust is to add the client-side > call to the history object to your response.write that raises the alert: > > Response.Write "<" & "script>alert('" & strMSG & "');" & _ > "window.history.back();" & "<" & "/script>" > Response.End > > By the way, the above can be simplified by switching out of the > server-side code block: > > <% > ... OTHER CODE HERE > > If NOT rsAccounts.EOF Then > rsAccounts.close > > strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" > strMSG = strMsg & "You have already made your selections!\n\n" > strMSG = strMsg & "Email the adminsitrator to have them deleted!" > %> > <script type="text/javascript"> > alert('<%= strMSG %>'); > window.history.back(); > </script> > <% > Response.End > End If > .%> > > Alexis Faren wrote: >> Sorry folks, my bad. I said the PREVIOUS Page, but it could be any >> page. >> >> Sorry about that. >> >> Alexis. >> "Alexis Faren" <alexis.fe***@mentorits.com> wrote in message >> news:uptEdI4uJHA.5684@TK2MSFTNGP03.phx.gbl... >> Good Easter to all. >> >> I am using this code to raise an Alert and it works fine. What I'd >> like to do is to redirect the user to the previous page based on this >> script: >> >> ... OTHER CODE HERE >> >> If NOT rsAccounts.EOF Then >> rsAccounts.close >> >> strMSG = "HOLD ON " & UCase(session("LoggedUser")) & "!\n\n" >> strMSG = strMsg & "You have already made your selections!\n\n" >> strMSG = strMsg & "Email the adminsitrator to have them >> deleted!" >> >> Response.Write("<" & "script>alert('" & strMSG & "');" & "<" & >> "/script>") >> >> End if >> %> >> >> I've tried using location.href and response.redirect to no avail. >> >> I need to do this right after Response.Write. >> >> Could someone point me in the right direction please? >> >> Thanks to all > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > >
Other interesting topics
Cdonts
pass cookie from one domain to another on the same server Asp and Mysql MSXML installation help New host needed infinite hierarchy webpages Behavior of ADODB.Command .Execute changes on different servers??? ASP on a home computer Re: Looking up ISP domains from IP addresses menu.asp in Commerce Server 2000 |
|||||||||||||||||||||||