redirect to prev page

I am using ASP Classic.

I am currently using the script below on a page that has a stored procedure. It redirects to a specific page.

<script language="javascript">

I need to tweak it so that it redirects to the PREVIOUS page.

Right now I have two pages that go to this one and because the redirect is fixed I need to pages to go back to the correct previous page.
Hope that makes sense.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
a quick fix is using history.back()

<script language="javascript">

Open in new window

see if this serve the purpose, or else you could probably do this by referring to server side variable HTTP_REFERRER and redirect accordingly.

<script language="javascript">
window.location.href="<%= Request.ServerVariables("HTTP_REFERER")%>";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Second option worked perfectly, thanks !
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you are using a server side language, why would you use javascript?  If your are hitting your SP via a javascript ajax call, then using js to go back makes sense.  If your user is directed to a page (even if they don't "see" it) by your asp code, then you would probably be better off using response.redirect.

set Conn = Server.createObject("ADODB.Connection")
set Cmd = Server.createObject("ADODB.Command")
set Cmd.activeConnection = Conn
Cmd.commandType = adCmdStoredProc
' stored proc code
set Cmd.activeConnection = nothing
set Cmd = nothing

set Conn = nothing

' now redirect

Open in new window

AleksAuthor Commented:
Sorry forgot to click accept.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.