Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iframe Browser Back Button trap 1

Status
Not open for further replies.

wrathyimp

Technical User
Oct 8, 2003
46
KW
hi,

I am looking to solve the back button issue with iframes, I have found a trick to resolve this iframe back button issue, but didnt really understood the technique, so can anyone help me understand the concept mentioned under the following links:
Method 3 from the following link:

I would like to use least javascript, as my page is asp.net (aspx)

Thanks all,
 
Back button is one of the most consistent mechanisms on the web and a concept every web surfer is familiar with? Why would you want to disable such a function?

I would suggest you find a better approach to what you're looking for, rather than disabling back button.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks for you Comment,

But i am not disabling, I have a start page, which have an iframe of images, these images link to a third pages, basically gallery of the images. So when I click on the images it take me to the gallery page, Now when i click the browser back button, I am returned back to the gallery page, I cannot go back to the previous page using the browser back button, I can use the site's menu without any issues.
But the browser back will not take me to the previous page.

So I need to resolve the Back Button issue.
 
Really, your page is just doing what you're asking it to do. And it is indeed a javascript redirection that is at fault here.

In the head section of your pages, you have a javascript script that does a simple thing. It checks the browser address bar and compares it to the loaded page: if the two differ, than it forwards the user to the loaded page. This is a script that escapes from frames (if your page was called from a frame, this script would make it load on its own).

This script performs a redirection. Now let's look at your code. You have a page with an iframe. This iframe does not have the above mentioned script. When you click on the links in the iframe, another page opens, the gallery page, which does have that redirection. As soon as the gallery page opens, your script checks if the addresses match and when they don't, you're forwarded to the gallery page. When you press back on your browser, you are returned to the front page with iframe of the gallery loaded (which again performs the check and redirects). This constantly redirects you to the gallery page.

You need to remove the script that checks for frames, at least from the pages that load in the iframe. Additionally, you should add [tt]target="_top"[/tt] to your links in the first iframe, to make the pages open in their own frame, instead of inside an iframe. Probably the second solution would've eliminated all your problems.

All in all, I think you should done away with the iframes. You have a dynamic page and including those gallery links to the main page should not be too difficult.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top