开发者

Prevent browser's back button from reopening pop up window on previous page

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.


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?


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..


The page was redirecting to itself and inserting the javascript code to pop up a new window based on the button pressed previously. I think it determined this via the post or get methods. I forget now.

As such, when the user presses the back button, they will reload the page with the embedded javascript code and not the original page.

We've since left classic ASP behind so I can't really test any suggestions but appreciate the help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜