How to set a response redirect to go back one page

Posted on 2007-11-28
Last Modified: 2009-07-29

I have a form which has a response redirect at the end. I'd like this to go back one page (ie the page before the form page) can I do this with javascript?


The code of the form is

if (Request.Form("Submit")) = "Submit" then
		emailmsg = ""
		for each thing in request.form
			emailmsg = emailmsg & trim(thing) & ": " & trim(request.form(thing)) & vbcrlf 
		set msg = Server.CreateOBject( "JMail.Message" )
		msg.Logging = true
		msg.silent = false
		msg.From = request.form("email")		
		msg.AddRecipient "sales@"			'Recipient of emailed form
		msg.Subject = "Stock enquiry"					'Subject of Email
		msg.Body = cstr(EmailMsg)
		msg.Send( "" ) 			'Change this to www2, www3 etc
		response.redirect "thank_you_mail.asp"				'address of thank you page
	end if

Open in new window

Question by:swordfishsoup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 82

Expert Comment

ID: 20365989
You can send this javascript snippet to the client:
<script type="text/javascript">
top.location.href= "";

where x and y are "variables" you may wish to pass onto the page before the form.
LVL 30

Expert Comment

ID: 20366051
my advice is to put the referrer on a hidden form field. then use this to redirect to your previous page.
LVL 30

Accepted Solution

third earned 500 total points
ID: 20366073
hmm, the code snippet portion is new. ok here,

<input type="hidden" name="redirPage" value="<%=Request.ServerVariables("http_referer")%>">
then on your page
response.redirect Request("redirPage")

Open in new window


Author Comment

ID: 20366157
Fantastic, works a treat.

Thanks very much 'third'

LVL 30

Expert Comment

ID: 20366182
welcome. ;-)

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tools for analysis of code 4 49
How to escape unsafe HTML tags 4 36
null, truthy, falsey confusion 25 33
setInterval() calls function twice in one interval 2 36
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question