views:

167

answers:

3

How would I prevent the browser from opening the pop up window that was displayed from the previous page when the user clicks the back button?

I hope that made sense but I'll explain it in point form below:

There are three pages: Page1, Page2, Page3

  1. User loads Page1 and clicks a link to load Page2 in a new window using JavaScript (i.e. window.open(...)). The User can close Page2 anytime they wish-- but we'll assume the user does so before step 2.

  2. User now clicks a link on Page1 to load Page3.

  3. User is now on Page3 and clicks the back button on their browser.

  4. Page1 is displayed in the browser but Page2 is displayed again in a pop up window.

So, I'm wondering if there is a way to prevent Page2 from popping up again. I am using classic ASP as well, if it matters.

+1  A: 

If Page2 is opened as a result of clicking a link, how is it automatically being opened when the back button is clicked? Unless Page2 is opened automatically on the initial load of Page1, it shouldn't pop up due to the back button being pressed - pressing "Back" doesn't click a link on the previous page. I suspect something else is going on in your page - can we see some code please?

BradBrening
A: 

I am having the same problem. I am using ASP.net (vb) I tried putting code like: Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.Cache.SetExpires(DateTime.Now.AddDays(-1)) in the popup page load code but it isn't working.

Jenny
A: 

you can try creating a session variable on page2. and check if it exist upon opening of page1. or use a cookie.

EDIT:

Function IsPostBack()
    IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function

this will not detect a page refresh though..

Noam Smadja