Solved

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

Posted on 1998-10-06
18
168 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
ID: 1855510
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
ID: 1855511
I'll check this out once I am at my work machine and let you know.
0
 
LVL 1

Author Comment

by:SteveWood
ID: 1855512
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 1

Author Comment

by:SteveWood
ID: 1855513
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
ID: 1855514
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
ID: 1855515
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
ID: 1855516
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
ID: 1855517
That only works if you don't have nested framesets. Then better try:

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

Author Comment

by:SteveWood
ID: 1855518
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
 
LVL 75

Expert Comment

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

Michel
0
 
LVL 1

Author Comment

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

Expert Comment

by:cermisch
ID: 1855521
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
ID: 1855522
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
ID: 1855523
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
ID: 1855524
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
ID: 1855525
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
ID: 1855526
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
ID: 1855527
IE will only allow -1, 0 or 1 in the go()

Michel
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.

810 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