Solved

URGENT - Getting the User back to where they came from.

Posted on 1998-10-06
18
166 Views
Last Modified: 2013-12-25
I have a frame set on my site.  In the corner I thought I would put an exit button that will take the user to the page they linked in from, taking any other framesets into account.  I tried HTTP_REFERRER, but that doesn't replace the previous frameset.  I have also tried using history.back() but with little success.

All my points to who ever can come up with a quick solution.

Cheers.
0
Comment
Question by:SteveWood
  • 9
  • 4
  • 3
  • +2
18 Comments
 
LVL 28

Expert Comment

by:sybe
Comment Utility
javascript:
In your frameset put
<script>
var ref = document.referrer;
</script>

The if the frameset stays the same, you can make a javascript call like:

<script>
window.location = window.ref;
</script>


0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
I'll check this out once I am at my work machine and let you know.
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
document.referrer works in the same way as HTTP_REFERRER i.e. it will take you back to the *page* the user comes from but not the frame set.  I will edit the question to try and make it clearer to what I need.  Thanks anyway.
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
Is it possible to get the URL's from within the history object so that I can set a parameter to one of the values?
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
Ok, I see what you want now.

The history object can not be read. This is for security reasons. If you will be able to read it, then you have discovered a security bug !.

But you can use

window.history.go(-1);

That will bring back the previous frameset.
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
Yep this works ok.  So long as there is no navigation within my frmae set.  If I navigate around my frameset then hit the exit button I just get taken back a page.

I have managed to get a solution to work in IE4.  This uses a combination of javascript using history.go() and dumping some values in the parent file, i.e. the page that creates the frameset.  This works well.  However I cannot get this to function in IE3+ or Netscape.  Is there a problem with using history.lenght in these browsers?

Thanks for your responses to date.  Looks like I will be giving you the points for your efforts.  But I want to see if I can get this wokring in the majority of browsers first.

Cheers.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
To get the main browser to go back, try parent.history.go(-1);
since Netscape's history is document based and IE's is window based.
Michel
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
That only works if you don't have nested framesets. Then better try:

top.history.go(-1)
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
Parent.history.go() and parent.history.back() have been tried but neither do what I need.

I will have a look at top.history.go() but I think that this will still function the way I want.  However I will have a look and let you know.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Yes, parent or top... depends on what needs to be sent back.

Michel
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
Sorry guys.  I can't top.history.go() to work the way I want either.
0
 

Expert Comment

by:cermisch
Comment Utility
Hi,

have you tried to do it via a cookie?
I am not sure if it works, but how about that:
When the user enters your site, set a cookie with the refferer. The EXIT-Button reads the contents of teh cookie and sends the user to that site.
Please let me know, if it is working.

Chris.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
cermish:
1. referrer is not set in ie3
2. SteveWood had already discarded referrer as a bad choice
3. Use a comment if you are not sure it will work - if Steve agrees, repost as an answer.

Steve: What happened with top.history.go(-1)???

If the referring page is your own, you can pass the name of the top level frameset and the pagenames of the frames in the location.search on the link to the current frameset. I can give you an example if you are interested.

Michel


0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
A cookie would do the job, I'm sure, but I need to be able to do it without using this things.

Any more suggestions anyone?
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
mplungjan - majority of the time the reffering pages will be mine.  But this still leaves a vast number of pages that are out of my control.
0
 
LVL 1

Accepted Solution

by:
Timbuk3 earned 110 total points
Comment Utility
i'm not sure of the exact coding of this, but let me give you the idea...

you said that window.history.go(-1); will work for you as long as there is no navigation on your frameset... what if you modify the code so it is something like this...

counter= 1;
onClick(counter++);

in each link on your page, call the onClick function.  then when the person clicks the back button just perform call this task:
window.history.go(-counter);

hope that is a viable solution.
0
 
LVL 1

Author Comment

by:SteveWood
Comment Utility
As with the cookie solution I am sure this will work.  However I am no working on this project.  I'm giving you the points as you have sugessted a solution that will work with most browsers.

Thanks to everyone for help on this.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
IE will only allow -1, 0 or 1 in the go()

Michel
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
extra space below iframe 9 51
Want to build a web site for a business. Where to start? 9 34
WEB Farm 6 21
modify h2 4 8
Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now