Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-10-06
18
Medium Priority
?
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
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:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

636 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